I am trying to programmatically access the headers of a response.
PS: Using Chrome. If I add a breakpoint and inspect the response object, it looks like it has no headers.
If I try print of the headers, both of these log statements show {}:
const response = await fetch(request);
console.log('headers stringify:', response.headers);
console.log('headers:', JSON.stringify(response.headers));
However in the Chrome dev tools Network tab it shows the response had headers. How does one access the headers of a response object?
Thanks to @alittleSalty for the link which explains the headers are an iterable, and can be seen with:
response.headers.forEach((value, key) => console.log("header:", key, 'value:', value));