Angular8 get full of HttpClient response headers

Viewed 1120

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.

The HttpClient response headers

The Http response headers

How can I get the ETag from response Header

2 Answers

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

enter image description here

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

Related