Created
September 15, 2020 23:46
-
-
Save trev-dev/ff866b707dcd471ec29290e788c06dbf to your computer and use it in GitHub Desktop.
I can haz dadjoke plz
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /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