(fix) fetch is not defined error
See original GitHub issueDescribe the bug I am using cognito with serverless-http app. I encountered some error about Reference error in Cloudwatch when I request my serverless app.
ReferenceError: fetch is not defined
at Client.request (/var/task/node_modules/amazon-cognito-identity-js/lib/Client.js:55:5)
at /var/task/node_modules/amazon-cognito-identity-js/lib/CognitoUser.js:313:21
at AuthenticationHelper.getLargeAValue (/var/task/node_modules/amazon-cognito-identity-js/lib/AuthenticationHelper.js:85:7)
at CognitoUser.authenticateUserDefaultAuth (/var/task/node_modules/amazon-cognito-identity-js/lib/CognitoUser.js:291:26)
at CognitoUser.authenticateUser (/var/task/node_modules/amazon-cognito-identity-js/lib/CognitoUser.js:252:19)
at login (/var/task/src/serverless.js:277:17)
at Layer.handle [as handle_request] (/var/task/node_modules/express/lib/router/layer.js:95:5)
at next (/var/task/node_modules/express/lib/router/route.js:137:13)
at Route.dispatch (/var/task/node_modules/express/lib/router/route.js:112:3)
at Layer.handle [as handle_request] (/var/task/node_modules/express/lib/router/layer.js:95:5)
To Reproduce Steps to reproduce the behavior:
- Go to ‘…’
- Click on ‘…’
- Scroll down to ‘…’
- See error
Expected behavior
So I tried to fix this error to edit amazon_cognito_identity-js in node_modules. But it can not be applied, so I carefully change above these commit. https://github.com/Q00/amazon-cognito-identity-js/commit/6a907ddcbee687495bf9c3a2286480606a454b05
After change, finally I get intended response like this
message: 'User does not exist.',
code: 'UserNotFoundException',
time: 2019-01-20T19:31:41.735Z,
requestId: '0364989e-1cea-11e9-a193-affb587e0cbd',
statusCode: 400,
retryable: false,
retryDelay: 28.517921067981966
I am junior with cognito so that I do not understand your intention perfectly. But these commit can help me deploy and service app without error. https://github.com/Q00/amazon-cognito-identity-js/commit/6a907ddcbee687495bf9c3a2286480606a454b05
Screenshots
Desktop (please complete the following information):
- OS: mac os
Additional context #403 this issue can not help me so I tried to edit this repo directly. I want to help people who get related this error. What can I do for this error?
You can turn on the debug mode to provide more info for us by setting window.LOG_LEVEL = ‘DEBUG’; in your app.
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (2 by maintainers)
I just tried this on node.js
I installed node-fetch on my node.js app
@chaitanya11 For Typescript you can do this: