aws-cognito-angular-quickstart icon indicating copy to clipboard operation
aws-cognito-angular-quickstart copied to clipboard

Cannot read property 'ddb' of undefined

Open aaaguirrep opened this issue 7 years ago • 1 comments

Hi, it is a good example of how to use aws cognito to users manage, I am beginning in the programming world and I am learning. I have tested the code and it is showing an issue in the console about "Cannot read property 'ddb' of undefined". I checked that it refers to aws.service.ts file and the line 95, there is a variable called ddb used. How and where should it be declared to remove the issue?

I have tried different ways and the issue doesn't disappear.

Thanks in advance.

I copy where the var is used.

addCognitoCredentials(idTokenJwt: string): void { let creds = this.cognitoUtil.buildCognitoCreds(idTokenJwt);

    AWS.config.credentials = creds;

    creds.get(function (err) {
        if (!err) {
            if (AwsUtil.firstLogin) {
                // save the login info to DDB
                this.ddb.writeLogEntry("login");
                AwsUtil.firstLogin = false;
            }
        }
    });
}

aaaguirrep avatar Apr 15 '18 20:04 aaaguirrep

More information, the issue occurs when: -Login in the app -Close the tap -Open the app and it appears in the console.

aaaguirrep avatar Apr 15 '18 22:04 aaaguirrep