I'm making a request using fetch to wordpress api, but I get a empty headers object on the response, anyone knows why?
here's my fetch action
export const getJobs = () => {
return dispatch => {
fetch(endpoints.jobs)
.then(res => res.json())
.then(data => dispatch(setJobs(data)))
}
};
and here's the object that I get before doing res.json
body: (...)
bodyUsed: false
headers: {}
ok: true
redirected: false
status: 200
statusText: "OK"
type: "cors"
url: "url"
any ideas on how I can get all the headers from the response?
There is a restriction on accessing response headers when using CORS. Since your response type is cors that might be the culprit.
See this answer for details.