1

How can I restructure this bit of code so that it uses a promise instead of a callback?

This is the code:

 var download = function(uri, filename, callback){
  request.head(uri, function(err, res, body){
    request(uri).pipe(fs.createWriteStream(filename)).on('close', callback);
  });
};
AKL012
  • 399
  • 5
  • 14

0 Answers0