3👍
context
inside function changes when you use function
keyword. Use arrow function to keep the context inside error handler same as parent scope. You are using it on your then handler, that’s why it’s working there.
.catch((error)=>{
this.errorMessage='Authentication failed';
})
Source:stackexchange.com