Guest User

Untitled

a guest
Feb 3rd, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. import { Injectable } from '@angular/core';
  2. import { HttpClient, HttpHeaders, HttpParams, HttpResponse } from '@angular/common/http';
  3. import { CookieService } from 'ngx-cookie-service';
  4.  
  5. @Injectable()
  6. export class AuthService {
  7. readonly endpoint = 'http://xxx.xxx.xxx.xxx:8081/login/';
  8. phpsessidCookieValue = '';
  9.  
  10. constructor(private readonly httpClient: HttpClient,
  11. private readonly cookieService: CookieService) { }
  12.  
  13. post(userName: string, password: string) {
  14. const body = new HttpParams()
  15. .set('username', userName)
  16. .set('password', password);
  17. const headers = new HttpHeaders()
  18. .append('Content-Type', 'application/x-www-form-urlencoded');
  19. const options = {
  20. headers: headers
  21. };
  22.  
  23. return this.httpClient.post(this.endpoint, body, options)
  24. .subscribe((response: HttpResponse<any>) => {
  25. console.log(response.headers); /*undefined*/
  26. });
  27. }
  28. }
Add Comment
Please, Sign In to add comment