![](/img/trans.png)
[英]Angular 6 HttpClient GET response not returning the custom headers
[英]Angular 8 HttpClient GET response not returning the custom headers
我试图在 http 请求后获取响应标头,但我无法获取它...
headers: HttpHeaders;
httpOptions;
constructor(private http: HttpClient) {
const token = localStorage.getItem("token");
this.headers = new HttpHeaders({
"Content-Type": "application/x-www-form-urlencoded"
}).set("x-auth-token", token);
this.httpOptions = {
headers: this.headers,
responseType: "text" as "json",
observe: "response"
};}
test<T>(url: string) {
return this.http.get<T>(url, this.httpOptions).pipe(
tap((res: HttpResponse<any>) => {
console.log(res.headers.keys())
}))
}
我试图得到这个:标题
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.