Guest User

Untitled

a guest
Dec 14th, 2017
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. login(username: string, password: string): Observable<boolean> {
  2. const url = this.getUrl('/v1/users/login');
  3. const headers = {
  4. headers: new HttpHeaders({'Content-Type': 'application/json', 'transactionId': uuid.v4()})
  5. };
  6. const body = { username, password };
  7.  
  8. return new Observable<boolean>( observer => {
  9. this.http.post<User>(url, body, headers).subscribe(
  10. (user: User) => {
  11. console.log('login: Success: ', user);
  12. observer.next(true);
  13. },
  14. (err: HttpErrorResponse) => {
  15. console.log('login: Error: ', err);
  16. observer.next(false);
  17. }
  18. );
  19. });
  20. }
Add Comment
Please, Sign In to add comment