Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import { Injectable } from '@angular/core';
- import { HttpClient, HttpHeaders, HttpParams, HttpResponse } from '@angular/common/http';
- import { CookieService } from 'ngx-cookie-service';
- @Injectable()
- export class AuthService {
- readonly endpoint = 'http://xxx.xxx.xxx.xxx:8081/login/';
- phpsessidCookieValue = '';
- constructor(private readonly httpClient: HttpClient,
- private readonly cookieService: CookieService) { }
- post(userName: string, password: string) {
- const body = new HttpParams()
- .set('username', userName)
- .set('password', password);
- const headers = new HttpHeaders()
- .append('Content-Type', 'application/x-www-form-urlencoded');
- const options = {
- headers: headers
- };
- return this.httpClient.post(this.endpoint, body, options)
- .subscribe((response: HttpResponse<any>) => {
- console.log(response.headers); /*undefined*/
- });
- }
- }
Add Comment
Please, Sign In to add comment