I'm trying to download and save a pdf file with nodejs and nightwatchjs, yet it does not work. PDF file remains empty (0kb) and I can't open it with Adobe Acrobat. Here's the code:
var url = "http://www.sait.ca/Documents/sample.pdf"
var file = fs.createWriteStream("form.pdf");
https.get(url, function(response){
response.pipe(file);
});
It looks like this method worked for others (see -> Download File, save it and read it again --> Error), but it does not for me. Am I missing something?
You need to call stream.end()
.