Created
May 8, 2016 15:55
-
-
Save stevester94/650101f336fe90b9f4a8f6be0c5e4ee1 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
var http = require('http'); | |
//The url we want is: 'www.random.org/integers/?num=1&min=1&max=10&col=1&base=10&format=plain&rnd=new' | |
var options = { | |
host: 'www.reddit.com', | |
path: '/index.html' | |
}; | |
callback = function(response) { | |
var str = ''; | |
//another chunk of data has been recieved, so append it to `str` | |
response.on('data', function (chunk) { | |
str += chunk; | |
}); | |
//the whole response has been recieved, so we just print it out here | |
response.on('end', function () { | |
console.log(str); | |
}); | |
} | |
http.request(options, callback).end(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment