I'm trying to set the this.signinError
within the catch block. however when the console.log(this.signinError);
is called it keep returning undefined
. When I do it before the function call, it returns an empty string as defined in the beginning of the class. What am I doing wrong here?
@inject(UserService)
export class LoginComponent {
email = '';
password = '';
signinError = '';
constructor(userService) {
this.userService = userService
}
login() {
console.log(this.signinError);
this.userService.login(this.email, this.password).catch(function(error) {
console.log(this.signinError);
this.signinError = error.message;
});
}
}