matthew-andrews / isomorphic-fetch

Isomorphic WHATWG Fetch API, for Node & Browserify
MIT License
6.95k stars 289 forks source link

Problem with accessing headers value #97

Open tutok opened 8 years ago

tutok commented 8 years ago

I have problem with accessing headers value. I can only read value of content-type. Am I doing something wrong?

I have code like this

return fetch(url)
            .then(response => {                    
                debugger;
                console.log(response.headers.get('Content-Type'))
                console.log(response.headers.get('Date'))
                return response;
            })
            .then(processStatus);

which prints: application/json; charset=utf-8 null

image

I have es6-promise installed, also added import "babel-polyfill"; on beginning of my scripts. I am using latest version which is 2.2.1

fedgrant commented 8 years ago

I am having the same issue in the AOSP browser. Works in chrome and FF though. Any insight would be greatly appreciated.

fuglu commented 8 years ago

We ran into the same issue today and fixed it by adding Location to the Access-Control-Expose-Headers: http://www.aaron-powell.com/posts/2013-11-28-accessing-location-header-in-cors-response.html

AlexChesters commented 7 years ago

I'm also seeing this, inspecting the network call I can see 7 response headers but using isomorphic-fetch I can only get the Content-Type header. Is this intentional?

AlexChesters commented 7 years ago

My above issue was resolved in the same way as @fuglu. I had to add the header I was trying to access to the Access-Control-Expose-Headers header.

carlosconnected commented 7 years ago

Same resolution as @fuglu https://github.com/matthew-andrews/isomorphic-fetch/issues/115

betoharres commented 7 years ago

@fuglu what's the point to set Location HTTP header in this case? I don't want to set a HTTP redirect nor I created something to define this variable, this is doesn't make any sense to me :( also the solution didn't work using it with electron.