Amplify admin query /listGroups not returning NextToken

0

When I try to use amplify admin query to get an array of all the user pool groups the max I can get is 60 but the response never has a nextToken in it self even when I change the limit to 25 or 50 (I have 61 user groups in userpool), I have tried a different admin query listUsers and that one correctly returns a NextToken. This is how the admin query called from cognitoActions.js file

async function listGroups(Limit, PaginationToken) {
  const params = {
    UserPoolId: userPoolId,
    ...(Limit && { Limit }),
    ...(PaginationToken && { PaginationToken }),
  };

  console.log('Attempting to list groups');

  try {
    const result = await cognitoIdentityServiceProvider
      .listGroups(params)
      .promise();

    // Rename to NextToken for consistency with other Cognito APIs
    result.NextToken = result.PaginationToken;
    delete result.PaginationToken;

    return result;
  } catch (err) {
    console.log(err);
    throw err;
  }
}

What I expect to happen here it to get 50 groups from the first run with a nextToken and finaly 11 from the next one with a nextToken that is undefined. It worked correctly with listUsers so I don't understand why listGroups doesn't work. The solution I've tried: https://github.com/aws-amplify/amplify-cli/issues/8362

 let nextToken;
      const results = [];
      const apiName = 'AdminQueries';
      const path = '/listGroups';
      do {
        const myInit = {
          queryStringParameters: {
            limit: 50,
            token: nextToken,
          },
          headers: {
            'Content-Type': 'application/json',
            Authorization: `${(await Auth.currentSession())
              .getAccessToken()
              .getJwtToken()}`,
          },
        };
        const response = await API.get(apiName, path, myInit);
        const { NextToken, Groups } = response;
        nextToken = NextToken;
        results.push(...Groups);
      } while (nextToken);
      console.log(results);

      return results;
No Answers

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions