Converting fetch’s response headers to a plain serializable JavaScript object
1 min readApr 25, 2019
fetch’s response is an object that has a headers
property. But this property is of type Headers which is not serializable.
Here’s a little function that convert response headers into a simple JavaScript object ready to be serialized or printed to the console.
Update: the code is updated in 2020–06–01 using Object.fromEntries()
. Thanks Matthias Etienne for the awesome tip in the comment.