Download PDF using code in Zapier

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);
+4
source share
1 answer

. - Dropbox, " JavaScript" JavaScript.

PDF , res.buffer() res.text(), fs.writeFile().

0

Source: https://habr.com/ru/post/1669328/


All Articles