Unable to get Headers
I'm requesting data from Wordpress Api, which serves some data in response headers:
X-WP-Total: the total number of records in the collection
X-WP-TotalPages: the total number of pages encompassing all available records
But on Logging response get empty object. see below image

But in network request getting headers. see below image

Please resolve this issue, if not already or Guide me with the solution.
Facing the same issue. Also using wordpress but the headers are empty.
After searching for a solution I found this: The Headers class instance that fetch returns is an iterable, as opposed to a plain object like axios returns. Some iterable's data, such as Headers or URLSearchParams, aren't viewable from the console, you have to iterate it and console.log each element, like:
fetch('http://localhost:9876/test/sample-download', {
method: 'post',
headers: {},
body: {}
})
.then(response => {
// Inspect the headers in the response
response.headers.forEach(console.log);
// OR you can do this
for(let entry of response.headers.entries()) {
console.log(entry);
}
})
.catch(err => console.error(err));
Resource: https://stackoverflow.com/questions/48413050/missing-headers-in-fetch-response
So in Nuxt you can use:
const res = await this.$http.get('https://localhost:3000/wordpress/wp-json/wc/v3/products/')
res.headers.forEach(console.log)