im trying to get the response header after http request and i cant get it...
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())
}))
}
im trying to get this: header
take a look at this: Get-Full-Response
I tried this code here and it works:
this.http.get(this.url, { observe: `response` })
.subscribe((res) => {
console.log(res);
})
I used subscribe instead of pipe. This was the response:
I'm not sure if this was helpfull.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.