Skip to content

Commit

Permalink
Update advanced/chat.gs
Browse files Browse the repository at this point in the history
Co-authored-by: Gustavo Tondello <[email protected]>
  • Loading branch information
danielatgoogle and gtondello authored Oct 27, 2023
1 parent 7d7befa commit a27b341
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions advanced/chat.gs
Original file line number Diff line number Diff line change
Expand Up @@ -95,19 +95,21 @@ function listMemberships(spaceName) {
let response;
let pageToken = null;
try {
response = Chat.Spaces.Members.list(spaceName, {
pageSize: 10,
pageToken: pageToken
});
if (!response.memberships || response.memberships.length === 0) {
do {
response = Chat.Spaces.Members.list(spaceName, {
pageSize: 10,
pageToken: pageToken
});
if (!response.memberships || response.memberships.length === 0) {
pageToken = response.nextPageToken;
continue;
}
response.memberships.forEach(member => console.log(
'Member resource name: %s (type: %s)',
membership.name,
membership.member.type);
pageToken = response.nextPageToken;
continue;
}
response.memberships.forEach(member => console.log(
'Member resource name: %s (type: %s)',
membership.name,
membership.member.type);
pageToken = response.nextPageToken;
} while (pageToken);
} catch (err) {
// TODO (developer) - Handle exception
console.log('Failed with error %s', err.message);
Expand Down

0 comments on commit a27b341

Please sign in to comment.