baniol
11/9/2015 - 7:53 PM

index.js

{
  "name": "chuck_cow",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC"
}
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));
}