Skip to content

Instantly share code, notes, and snippets.

@manchuck
Last active July 8, 2019 13:38
Show Gist options
  • Save manchuck/c2e36f215104fd126c76a93bdc66ba41 to your computer and use it in GitHub Desktop.
Save manchuck/c2e36f215104fd126c76a93bdc66ba41 to your computer and use it in GitHub Desktop.
const fetchUsersFromCognito = async (
cognitoService,
userPoolId,
limit = 60,
pageToken = null,
) => {
// Not documented in AWS docs but the max limit for this service is 60
if (limit > 60 || limit < 1) {
throw new Error('Invalid range for limit');
}
try {
return await cognitoService.listUsers({
Limit: limit,
UserPoolId: userPoolId,
PaginationToken: pageToken,
}).promise();
} catch (error) {
throw error;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment