When I am trying to login Getting this error
Unknown error, the response body from fetch is: undefined
Here Is my code What I have done
// console.log(request)
const loginDetails = {
Username: '[email protected]',
Password: '*****'
}
const authenticationDetails = new AmazonCogintoIdentity.AuthenticationDetails(loginDetails)
const userDetails = {
Username: '[email protected]',
Pool: userPool
}
const cognitoUser = new AmazonCogintoIdentity.CognitoUser(userDetails)
cognitoUser.authenticateUser(authenticationDetails, {
onSuccess: function (result) {
console.log('access token + ' + result.getAccessToken().getJwtToken());
console.log('id token + ' + result.getIdToken().getJwtToken());
console.log('refresh token + ' + result.getRefreshToken().getToken());
console.log(result)
},
onFailure: function(err) {
console.log(err);
// console.log('not onSuccess')
},
});
please Help me to solve this error
@Aslamdesusa are you using this in Node.js? If so, you need to install a node-fetch:
https://aws-amplify.github.io/amplify-js/media/authentication_guide#nodejs-support
Thank you @mlabieniec it was helpful
@Aslamdesusa are you using this in Node.js? If so, you need to install a node-fetch:
https://aws-amplify.github.io/amplify-js/media/authentication_guide#nodejs-support
Link fails to refer ^^^
I got the same error, Im using Web browser to login.
I moved to CognitoIdentityServiceProvider from 'aws-sdk'. It had all the functionality i needed, and worked.
https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/CognitoIdentityServiceProvider.html
Typescript Node solution.
Closing the issue as you will no longer receive unknown error in the latest version.
Most helpful comment
I got the same error, Im using Web browser to login.