Why does Request and Fetch return different headers?
Are the headers in Response objects always limited using Fetch? Despite it being used on server, various modes used?
Request seems to return a rich set of headers, while Fetch does not.
Other than language mechanic differences (Promise based, Callback, etc..etc..) How do these two differ? Why is one not returning a rich set of headers and the other is?
fileURL
used in both examples are cross domain. On a Node/Express server, a call is made to a Google CDN.
Using Request
https://github.com/request/request
request(fileURL, (err, res, body) => {
//headers in res
//are pretty rich
});
Using Fetch
https://github.com/matthew-andrews/isomorphic-fetch
https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch
const reqConfig = { method: 'POST',
headers: myHeaders,
body: data,
mode: 'cors', //or 'no-cors', or this field blank..
cache: 'default' };
fetch(fileURL, reqConfig).then(res => {
//headers in res
//are not very complete
})
// I don't have access to CORS policies on server so that is not an option..
edit Even when operating in {mode: 'no-cors'} the headers are not full..