Skip to content

Instantly share code, notes, and snippets.

@agreen757
Created May 20, 2015 16:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save agreen757/41324563304cf330ce12 to your computer and use it in GitHub Desktop.
Save agreen757/41324563304cf330ce12 to your computer and use it in GitHub Desktop.
Downloading files using Request module in Node.js
function downloader(url,title,token){
var file = fs.createWriteStream(title);
var options = {
url: url,
headers: {
Authorization: 'Bearer '+token
}
}
request(options).pipe(file).on('close',function(){
console.log('done')
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment