简体   繁体   中英

Angular8 get full of HttpClient response headers

I'm using HttpClient to request a json file. I want the file can be cached with ETag . But it not works. I think that The If-None-Match not send to the server is the reason. So I want to get The 'ETag' from response headers. But the response header not has the item in Angular, But It's truly in the HTTP response in chrome network tool. All of showing in follow images.

HttpClient 响应头

Http 响应头

How can I get the ETag from response Header

I think it's similar to this : HttpClient dont return all headers .

You need to setup your backend to return Access-Control-Expose-Headers:ETag .

As the MDN shows the cors hide lots of headers, So I can't get the ETag in angular.

在此处输入图片说明

Add Access-Control-Expose-Headers:ETag to response header can solve this issue.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM