Angular 4 new HttpClient content headers

I am trying to get a file (array buffer) from my backend using the new HttpClient.

My code is similar to the following:

this.http.post(url, body, {responseType: 'blob', observe: 'response'}) .subscribe(resp => { console.log(resp.headers.get('content-disposition')); }); 

The response in my browser console is null

When I look at the network tab, I see that the content has a value similar to the attachment; file name = "all"

If I try to get the content type instead, I will get something.

Have you experienced something like this, or can you tell me what I should do differently? Thank you very much

+5
source share
1 answer

I had the same problem and found this fooobar.com/questions/1273173 / ...

It worked for me after adding 'Access-Control-Expose-Headers': 'Content-Disposition' to the header of my backend response.

+5
source

Source: https://habr.com/ru/post/1273170/


All Articles