Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Download file with Node
// download: download the url to string = function(url, cb){
var options = require('url').parse(url),
httpx = url.startsWith(url, 'https:') ? https : http,
data = "",
req = httpx.request(options, function(res){
res.on("data", function(chunk){
return data += chunk;
return res.on("end", function(){
return cb(null, data, url);
return req.end()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.