Skip to content

Instantly share code, notes, and snippets.

@alexewerlof
Last active February 22, 2023 16:59
Show Gist options
  • Save alexewerlof/fedfe80d59aa1c096267600595ba423e to your computer and use it in GitHub Desktop.
Save alexewerlof/fedfe80d59aa1c096267600595ba423e to your computer and use it in GitHub Desktop.
converting fetch response headers to a plain javascript object
const fetch = require('node-fetch')
const am = require('am')
async function main() {
const url = 'https://www.example.com'
const response = await fetch(url)
const responseHeaders = Object.fromEntries(resp.headers.entries())
console.dir(responseHeaders)
return responseHeaders
}
am(main)
@alexkonst
Copy link

@alexewerlof
Copy link
Author

thanks @alexkonst. updated it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment