Q:

AWS Cognito login error on AngularJS

I'm making an user management with the cognito Amazon Webservice. 
I already manage the signing to my userPool but everyTime I'm trying to login to my user pool I've this console error : 
Error: this.pool.getUserPoolId is not a function

I don't know where is from getUserPoolId...
EDIT: I've my login function in a factory that's my code :
login: function(username, password) {
        var authenticationData = {
                Username : username,
                Password : password
        };
        var userData = {
                Username :username,
                Pool : poolData
        };
        var authenticationDetails = new AWSCognito. CognitoIdentityServiceProvider. AuthenticationDetails(authenticationData);

        var cognitoUser = new AWSCognito. CognitoIdentityServiceProvider. CognitoUser(userData);
        cognitoUser.authenticateUser(authenticationDetails, {
        onSuccess: function (result) {
            console.log('access token + ' + result.getAccessToken().getJwtToken());
            /*Use the idToken for Logins Map when Federating User Pools with Cognito Identity or when passing through an Authorization Header to an API Gateway Authorizer*/
            console.log('idToken + ' + result.idToken.jwtToken);
    },

    onFailure: function(err) {
            alert(err);
    },

        });
        }

Does anyone know what to do ? 

A:

The AWS Cognito JavaScript SDK initialization pattern requires that you pass "data objects" to an AWS SDK constructor.  In return, the SDK gives you back an AWS "interface" with various connection methods. 
I think from your code you used the data object instead of the subsequent interface. 
Example:
// Data Object used for initialization of the interface
const userPoolData = {
    UserPoolId: identityPoolId,
    ClientId: clientId
}

// The `userPoolInterface`, constructed from your `poolData` object
const userPoolInterface = new AWSCognito
    .CognitoIdentityServiceProvider
    .CognitoUserPool(userPoolData)

In the code you provided, it seems you are passing the userData object (used for initialization), where you should be passing the userPool interface that should have been previously initialized. 
Try this instead:
login: function(username, password) {

    // 1) Create the poolData object
    var poolData = {
        UserPoolId: identityPoolId,
        ClientId: clientId
    };

    // 2) Initialize the userPool interface
    var userPool = new AWSCognito
        .CognitoIdentityServiceProvider
        .CognitoUserPool(poolData)

    // 3) Be sure to use `userPool`, not `poolData`
    var userData = {
        Username : username,
        Pool : poolData,  // <-- Data?!  Oops..
        Pool : userPool  // "interface", that's better :)
    };

    var authenticationData = {
        Username : username,
        Password : password
    };

    var cognitoUser = new AWSCognito
        .CognitoIdentityServiceProvider
        .CognitoUser(userData)

    var authenticationDetails = new AWSCognito
        .CognitoIdentityServiceProvider
        .AuthenticationDetails(authenticationData);

    cognitoUser.authenticateUser( ...etc... );
}

Try it online:
If it helps, I am taking notes and making examples, while I walk through the AWS Cognito SDK examples.  You are welcome to checkout the Github repo I am using.  It might help if you can test out a working example. 
Github Repository
 / Live Demo

