英文:
Why I get only two headers in Angular using HttpClient?
问题
I'm trying to get all headers from the response to a post method:
this.http.post<User>(this.url, user, {
observe: 'response',
responseType: 'json',
})
.subscribe((res) => {
console.log('Headers: ' + JSON.stringify(res.headers));
});
}
earlier:
url = 'http://localhost:8080/user/login';
constructor(private http: HttpClient) {}
I followed most tutorials and stackoverflow answers, but I get only two headers:
Headers: {"normalizedNames":{},"lazyUpdate":null}
When I tried with postman and curl everything works fine, that is I get all the headers, but not in Angular (I'm using version Angular CLI: 15.2.8)
英文:
I'm trying to get all headers from the response to a post method:
this.http.post<User>(this.url, user, {
observe: 'response',
responseType: 'json',
})
.subscribe((res) => {
console.log('Headers: ' + JSON.stringify(res.headers));
});
}
earlier:
url = 'http://localhost:8080/user/login';
constructor(private http: HttpClient) {}
I followed most tutorials and stackoverflow answers, but I get only two headers:
Headers: {"normalizedNames":{},"lazyUpdate":null}
When I tried with postman and curl everything works fine, that is I get all the headers, but not in Angular (I'm using version Angular CLI: 15.2.8)
答案1
得分: 1
请检查这个链接 - https://stackoverflow.com/questions/52443706/angular-httpclient-missing-response-headers
在您的情况下,似乎第二个答案可能会对您有帮助,关于标头的延迟加载。
英文:
Check this one - https://stackoverflow.com/questions/52443706/angular-httpclient-missing-response-headers
In your case seems that second answer might help you, about headers being lazy loaded
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论