I am trying to download a PDF from a website using Javascript in the "Code" step in Zapier. I am struggling to find documentation on how to output the file object. Here is my basic code so far. unfortunately, the file that comes back is garbage characters. Perhaps it needs to be encoded? I would also like any advice you might have on how I would modify this code if the file I wanted was on a website that required basic authentication. Any advice would be greatly appreciated:
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);