I am trying to download a PDF file from a website using Javascript at the βCodeβ stage in Zapier. I'm struggling to find documentation on how to output a file object. Here is my base code. Unfortunately, the file that is returned is a garbage symbol. Perhaps it needs to be encoded? I would also like to get any tips on how to change this code if the file I wanted was on a website that required basic authentication. Any advice would be very helpful:
fetch('http://www.pdf995.com/samples/pdf.pdf')
.then(function(res) {
return res.text();
})
.then(function(body) {
var output = {id: 1234, myPDF: body};
callback(null, output);
})
.catch(callback);
source
share