Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public loginuser(username : String , password : String){
- const body = {
- username : username,
- password : password,
- }
- var reqHeader = new HttpHeaders({'No-Auth':'True' });
- return this.http.post(this.rootUrl + '/access/login', body ,{ headers: reqHeader });
- }
- OnSubmit(form: NgForm){
- this.userService.loginuser(this.username,this.password).subscribe(
- (data : any)=>{
- console.log(data);
- localStorage.setItem('userToken',data.token);
- this.router.navigate(['/login']);
- },
- (err : HttpErrorResponse)=>{
- console.log(err.error);
- }
- );
- }
- http code : 201
- {token : "the token"}
- http code : 404
- {
- "status_code":31,
- "status_message":"Username or password invalid"
- }
Add Comment
Please, Sign In to add comment