Skip to content

Instantly share code, notes, and snippets.

@claytonbez
Created July 30, 2018 12:22
Show Gist options
  • Save claytonbez/7e161412b1992d29d78db11dcc437e2d to your computer and use it in GitHub Desktop.
Save claytonbez/7e161412b1992d29d78db11dcc437e2d to your computer and use it in GitHub Desktop.
Using the request module to download a file.
var http = require('http');
var fs = require('fs');
var file = fs.createWriteStream("file.jpg");
var request = http.get("http://i3.ytimg.com/vi/J---aiyznGQ/mqdefault.jpg", function(response) {
response.pipe(file);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment