amazon-archives / amazon-cognito-auth-js

The Amazon Cognito Auth SDK for JavaScript simplifies adding sign-up, sign-in with user profile functionality to web apps.
Apache License 2.0
423 stars 232 forks source link

Uncaught TypeError: AWSCognito.CognitoIdentityServiceProvider.CognitoAuth is not a constructor #4

Closed raviji closed 7 years ago

raviji commented 7 years ago

How to fix this error Uncaught TypeError: AWSCognito.CognitoIdentityServiceProvider.CognitoAuth is not a constructor

mymattcarroll commented 7 years ago

@raviji I only got this issue after running npm run build which replaced the files in the dist directory.

If you copy the files that are in the repo dist directory into the sample directory the issue is gone. :)

rcfrias commented 7 years ago

To fix this, you have to make sure both libraries are included in your html:

<script src="app/aws-cognito-sdk.js"></script>
<script src="app/amazon-cognito-auth.js"></script>

And if you are using Angular, you can have access to the constructor if you add this line in your file: declare var AWSCognito: any;

raviji commented 7 years ago

Thanks a lot @mymattcarroll & @rcfrias I fixed on June 6th itself.