Currently, I am in the process of developing an IONIC 3 application that consumes Asp.NET web API services. For authentication purposes, I have implemented Token based auth. When a user enters valid credentials, they receive a token which is then stored in the FireBase database. Conversely, if invalid credentials are entered, a toast message displaying an error is shown.
Although I am successfully receiving responses from the Observable, including both tokens and errors, I would like to enhance the user experience by displaying a toast specifically for bad credentials.
Given my limited experience with Rxjs and reactive programming, I am seeking advice on how to seamlessly integrate code for showing the toast within the subscribe method as illustrated below:
logUser(){
this.loginService.login(this.loginModel.userName,this.loginModel.password,this.loginModel.grant_type)
.subscribe(token => {this.Token= token ,
console.log(this.Token.access_token)},
error => this.errorMessage = <any>error);
//<any>this.toast.create(this.toastOptions).present()
}