Om Patel
Om Patel

Reputation: 3

How can I list all users from my Cognito Pool?

I'm making a new fullstack app using aws amplify gen2. I've just started working, and a critical functionality of my app is listing and managing current users in the cognito pool, however, the amplify docs don't have a guide on this but only the aws Cognito docs do. I tried to copy and paste some code into my app.tsx to list all users but I keep getting an error that my Region is missing. Below I have the code snippets pertaining my issue. How can I list and manage all users?

import { CognitoIdentityProviderClient, ListUsersCommand } from "@aws-sdk/client-cognito-identity-provider";

/... Other code .../

const listUsers = () => {
    const client = new CognitoIdentityProviderClient({});
  
    const command = new ListUsersCommand({
      UserPoolId: "My User Pool Id",
    });
  
     console.log(client.send(command));
 };

/... Other code .../

<button onClick={listUsers()}>Click</button>

/... Other code .../

I have tried to look for posts about this issue and other aws docs but nothing has helped.

Upvotes: 0

Views: 184

Answers (0)

Related Questions