Skip to content

Instantly share code, notes, and snippets.

@trev-dev
Created September 15, 2020 23:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trev-dev/ff866b707dcd471ec29290e788c06dbf to your computer and use it in GitHub Desktop.
Save trev-dev/ff866b707dcd471ec29290e788c06dbf to your computer and use it in GitHub Desktop.
I can haz dadjoke plz
#! /usr/bin/node
const https = require('https')
const options = {
headers: {
'Accept': 'application/json'
}
}
https.get('https://icanhazdadjoke.com', options, req => {
let data = ''
req.on('data', chunk => data += chunk)
req.on('end', () => console.log(JSON.parse(data).joke))
}).on('error', e => console.error(e))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment