'Angular - AWS Amplify amplify-authenticator crashes the form when the 'Code' I send is wrong
I have an amplify-authenticator form which I use to reset the password. If I enter a wrong code, I get a response from the API which says
CodeMismatchException: Invalid verification code provided, please try again.
which is correct, but the entire form then freezes and I also get this message in the console of the browser:
Error: Uncaught (in promise): TypeError: Cannot read properties of undefined (reading 'authAttributes') TypeError: Cannot read properties of undefined (reading 'authAttributes') at actorDoneData (index.js:2:34774)
which points to webpack:///node_modules/@aws-amplify/ui/dist/esm/index.js
This is the code I have:
HTML
<amplify-authenticator [services]="services" initialState="resetPassword"></amplify-authenticator>
TS
this.services = {
async handleForgotPasswordSubmit(formData): Promise<void> {
const { username, code, password } = formData;
return Auth.forgotPasswordSubmit(username, code, password)
.then(res => {
// Do something on success
})
.catch(err => {
// The ERROR is here
console.log(err);
});
}
};
Please advise what can I do to avoid the form freeze problem. Thanks!
EDIT: It seems that if I remove the .catch from the promise, the problem disappears.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
