![](/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.