Guest User

Untitled

a guest
Sep 4th, 2018
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. // import { map } from 'rxjs/operators'; // Fails at runtime
  2. import 'rxjs/add/operator/map'; // Works fine at runtime
  3.  
  4. public login(username: string, password: string): Observable<any> {
  5. console.log('Sending the login credentials to obtain a token');
  6. const credentials = { 'email': username, 'password': password };
  7. return this.httpService.postWithHeadersInResponse(URI_LOGIN, credentials)
  8. .map((response: HttpResponse<any>) => {
  9. const header = response.headers.get(this.authService.getHeaderName());
  10. const token = this.authService.extractTokenFromHeader(header);
  11. console.log('The token from the response header: ' + token);
  12. this.authService.setJwtTokenToLocalStorage(token);
  13. });
  14. }
Add Comment
Please, Sign In to add comment