Guest User

Untitled

a guest
Feb 17th, 2019
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. login() :void {
  2. if (this.loginForm.valid){
  3. this.userSrvc.login(this.loginForm.value).subscribe(
  4. res =>{
  5. console.log("success");
  6. },
  7. error => {
  8. console.log("login failed");
  9. }
  10. });
  11. }
  12. }
  13.  
  14. constructor(private http: HttpClient) {
  15. this.url = AppConstants.API_ENDPOINT;
  16. this.headers = new HttpHeaders({ 'Content-Type': 'application/json; charset=utf-8' });
  17. }
  18.  
  19. login(params: any): Observable<User> {
  20. console.log("service called");
  21. const body = JSON.stringify({ UserName: params.userid, Password: params.password });
  22. console.log("body", body);
  23. return this.http.post<User>(this.url + 'Login', body, { headers: this.headers });
  24. }
Add Comment
Please, Sign In to add comment