Response Header with fetch client

From backend, I provide Content-Disposition Header with file name. I test on postman and it’s giving me header with correct data. When I want to get this header in response everytime is giving me null.
response.headers.get("Content-Disposition");
Is it possible to get this header type with aurelia-fetch-client?

My version of “aurelia-fetch-client”: “^1.3.1”, and “whatwg-fetch”: “^2.0.3”.

1 Like

I use Aurelia-Api from spoonx and had a similar issue retrieving the etag from our api. My solution was to configure and use an interceptor. Snippet from main.js

good article on fetch-client interceptors here
http://foreverframe.net/using-interceptors-with-aurelia-fetch-client/

configure.withInterceptor({
response(response) {
if( response.headers.get(‘Content-Disposition’) !== null) {
localStorage.setItem(‘My-Key’,response.headers.get(‘Content-Disposition’));
}
return response;
}
});

https://github.com/github/fetch/issues/328

1 Like

@skeletonkeyz In interceptor I try to get header but nothing, it’s same I get only content type .
@Alexander-Taran in my app I have config cors to app.UseCors(CorsOptions.AllowAll);

Also in POSTAMN I have Content-Disposition heder

I would still try @Alexander-Taran 's solution, there is a .NET core example in the thread he linked.
This is a js access issue, response.headers.get(‘Content-Disposition’) won’t work, even if it’s visible in postman or even the devtools of your browser.

From the looks of it CorsOptions.AllowAll is for inbound…

I make reconfiguration on backend for CORS and now works good. Thank you :slight_smile:

2 Likes