Advertisement
Guest User

Untitled

a guest
Feb 21st, 2020
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.   headers: HttpHeaders;
  2.   httpOptions;
  3.  
  4.   constructor(private http: HttpClient) {
  5.     const token = localStorage.getItem("token");
  6.     this.headers = new HttpHeaders({
  7.       "Content-Type": "application/x-www-form-urlencoded"
  8.     }).set("x-auth-token", token);
  9.  
  10.     this.httpOptions = {
  11.       headers: this.headers,
  12.       responseType: "json",
  13.       observe: "response"
  14.     };
  15.   }
  16.  
  17.   test<T>(url: string) {
  18.     return this.http.get<T>(url, this.httpOptions).pipe(
  19.       map((res: HttpResponse<any>) => {
  20.       console.log(res.headers);
  21.       })
  22.     );
  23.   }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement