Adding a HTTP header to the Angular HttpClient doesn't send the header, why?

前端 未结 9 966
孤街浪徒
孤街浪徒 2020-11-22 05:45

Here is my code:

import { HttpClient, HttpErrorResponse, HttpHeaders } from \'@angular/common/http\';
9条回答
  •  北海茫月
    2020-11-22 06:24

    In the manual (https://angular.io/guide/http) I read: The HttpHeaders class is immutable, so every set() returns a new instance and applies the changes.

    The following code works for me with angular-4:

     return this.http.get(url, {headers: new HttpHeaders().set('UserEmail', email ) });
    

提交回复
热议问题