daily pastebin goal
57%
SHARE
TWEET

Untitled

a guest Mar 16th, 2018 77 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public loginuser(username : String , password :  String){
  2.       const body = {
  3.           username : username,
  4.           password : password,
  5.       }
  6.  
  7.       var reqHeader = new HttpHeaders({'No-Auth':'True' });
  8.       return this.http.post(this.rootUrl + '/access/login', body ,{ headers: reqHeader });
  9. }
  10.    
  11. OnSubmit(form: NgForm){
  12.  
  13.        this.userService.loginuser(this.username,this.password).subscribe(
  14.            (data : any)=>{
  15.                console.log(data);
  16.                localStorage.setItem('userToken',data.token);
  17.                this.router.navigate(['/login']);
  18.            },
  19.            (err : HttpErrorResponse)=>{
  20.                console.log(err.error);
  21.            }
  22.        );
  23.    }
  24.    
  25. http code : 201
  26. {token : "the token"}
  27.    
  28. http code : 404
  29. {
  30.     "status_code":31,
  31.     "status_message":"Username or password invalid"
  32. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top