I am having trouble retrieving response headers sent by the server. Despite being able to view the response headers in Chrome Dev Tools, when trying to access them using JavaScript, I am only getting an empty object.
(I am utilizing the isomorphic-fetch library for making XHR requests.)
fetch("http://my.cors.url/postsomedata", {
method: 'POST',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
},
body: JSON.stringify(myjsobject),
})
.then(response => response.headers)
.then((headers) => {
console.log(headers); // empty object
})
This question is distinct from the topic discussed in How to get Response headers in AJAX as I am not utilizing jQuery for this task.