-
-
Save jonaskahn/61da879abb43f9a5dcf815b0f72cdec2 to your computer and use it in GitHub Desktop.
Download file using GET and nodejs
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
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