From a27b34188dcee65e312dd6f0adbb0100774d81b1 Mon Sep 17 00:00:00 2001 From: Daniel Heinrich <148484595+danielatgoogle@users.noreply.github.com> Date: Fri, 27 Oct 2023 10:36:24 -0700 Subject: [PATCH] Update advanced/chat.gs Co-authored-by: Gustavo Tondello --- advanced/chat.gs | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/advanced/chat.gs b/advanced/chat.gs index 7be19cccd..90efb3fe3 100644 --- a/advanced/chat.gs +++ b/advanced/chat.gs @@ -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);