Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR TYPESCRIPT

angular subscribe catch stat

 signIn(user: Login) {
    //console.log("the path = "+this.loginPath);
    return this.http
      .post<any>(this.loginPath, user)
      .subscribe((res: any) => {
        localStorage.setItem('accessToken', res.accessToken);
        console.log(res);
        this._authenticated= true;
        this.router.navigate(['board']);

      },(error: any) => {
        console.log(error);
        if(error.status ==401){
          alert("Login or Password not exist");
        }
      },
        () => {
        console.log("Finally clause");
      }
      );
  }
 
PREVIOUS NEXT
Tagged: #angular #subscribe #catch #stat
ADD COMMENT
Topic
Name
3+1 =