Skip to content

Instantly share code, notes, and snippets.

@MarcoLugo
Forked from ialpert/nodejs.download.js
Created March 5, 2014 02:14
Show Gist options
  • Save MarcoLugo/9359951 to your computer and use it in GitHub Desktop.
Save MarcoLugo/9359951 to your computer and use it in GitHub Desktop.
function download(url, cb) {
var data = "";
var request = require("http").get(url, function(res) {
res.on('data', function(chunk) {
data += chunk;
});
res.on('end', function() {
cb(data);
})
});
request.on('error', function(e) {
console.log("Got error: " + e.message);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment