Skip to content

Instantly share code, notes, and snippets.

@alexewerlof
Last active February 22, 2023 16:59
Show Gist options
  • Select an option

  • Save alexewerlof/fedfe80d59aa1c096267600595ba423e to your computer and use it in GitHub Desktop.

Select an option

Save alexewerlof/fedfe80d59aa1c096267600595ba423e to your computer and use it in GitHub Desktop.

Revisions

  1. @userpixel userpixel revised this gist Aug 6, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion fetch-response-header.js
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,5 @@
    const fetch = require('node-fetch')
    comst am = require('am')
    const am = require('am')

    async function main() {
    const url = 'https://www.example.com'
  2. @userpixel userpixel revised this gist Jun 1, 2020. 1 changed file with 5 additions and 13 deletions.
    18 changes: 5 additions & 13 deletions fetch-response-header.js
    Original file line number Diff line number Diff line change
    @@ -1,20 +1,12 @@
    const fetch = require('node-fetch')

    function responseHeadersAsObject(response) {
    const headers = {}
    const keyVals = [...response.headers.entries()]
    keyVals.forEach(([key, val]) => {
    console.log(`${key}: ${val}`)
    headers[key] = val
    })
    return headers
    }
    comst am = require('am')

    async function main() {
    const url = 'https://www.aol.com'
    const url = 'https://www.example.com'
    const response = await fetch(url)
    const responseHeaders = responseHeadersAsObject(response)
    const responseHeaders = Object.fromEntries(resp.headers.entries())
    console.dir(responseHeaders)
    return responseHeaders
    }

    main().then(console.log, console.error)
    am(main)
  3. @userpixel userpixel renamed this gist Apr 25, 2019. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  4. @userpixel userpixel created this gist Apr 25, 2019.
    20 changes: 20 additions & 0 deletions fetch-response-header
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    const fetch = require('node-fetch')

    function responseHeadersAsObject(response) {
    const headers = {}
    const keyVals = [...response.headers.entries()]
    keyVals.forEach(([key, val]) => {
    console.log(`${key}: ${val}`)
    headers[key] = val
    })
    return headers
    }

    async function main() {
    const url = 'https://www.aol.com'
    const response = await fetch(url)
    const responseHeaders = responseHeadersAsObject(response)
    return responseHeaders
    }

    main().then(console.log, console.error)