AWS 使用 JS 从 aws cognito 获取所有用户

AWS getting all Users from aws cognitio with JS

如何从 aws cognito 获取所有用户?

我找到了这个:列出用户 http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/CognitoIdentityServiceProvider.html#listUsers-property

    var cognito = new AWSCognito.CognitoIdentityServiceProvider;

    cognito.listUsers(params, function(err, data) {
        if (err) console.log(err, err.stack); // an error occurred
        else     console.log(data);           // successful response
    });

但是当我这样做时我得到了这个错误:

没有定义 reagon ...

也试过这个:

  AWS.config.region = 'eu-central-1'; // Region
    AWS.config.credentials = new AWS.CognitoIdentityCredentials({
        IdentityPoolId: 'eu-central-1:',
        Logins: {
            'cognito-idp.eu-central-1.amazonaws.com/eu-central-1_': result.getIdToken().getJwtToken()
        }
    });

这里我得到的结果未定义...

如何获取所有用户?

这是一个工作示例:

let params = {
        UserPoolId: '<<PoolID>>',
        AttributesToGet: [
            'email',
            'family_name',
            'given_name',
            'custom:client',
            'phone_number'
        ],
        Limit: 0,
    };
    this.awsSDKAuth().listUsers(params, (err, data) => {
        if (err) console.log(err, err.stack); // an error occurred
        else {
            console.log(data.Users);
        }
    });