Skip to content

Instantly share code, notes, and snippets.

@baniol
Created November 9, 2015 19:53
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 baniol/092660a604fb139227f7 to your computer and use it in GitHub Desktop.
Save baniol/092660a604fb139227f7 to your computer and use it in GitHub Desktop.
var http = require('http');
var httpOptions = {
host: 'http://api.icndb.com/jokes',
// host: 'http://www.wp.pl',
path: 'random'
};
http.get(httpOptions, requestHandler);
function requestHandler(req) {
var body = '';
req.on('data', data => body += data);
req.on('end', () => console.log(body));
}
{
"name": "chuck_cow",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment