Node.js binary to PDF
问题 I have got a express server, which creates a pdf file. I am trying to send this file to the client: const fs = require('fs'); function download(req, res) { var filePath = '/../../myPdf.pdf'; fs.readFile(__dirname + filePath, function(err, data) { if (err) throw new Error(err); console.log('yeyy, no errors :)'); if (!data) throw new Error('Expected data, but got', data); console.log('got data', data); res.contentType('application/pdf'); res.send(data); }); } On the client I want to download it