I have currently a problem to fetch my pdf
from the backend to the front-end.
I'm using NodeJS.
I have all my pdf made with Puppeteer
and saved on a PDF directory.
I'm trying to fetch these PDF for the front-end
. (for download)
I'have tried with res.sendFile and res.download (res.sendFile(path.join(__dirname,"/path"), res.download(path.join(__dirname,"/path))
This is the response from the front-end:
{data: "%PDF-1.4↵%����↵1 0 obj↵<</Creator (Chromium)↵/Prod…e 7↵/Root 6 0 R↵/Info 1 0 R>>↵startxref↵675↵%%EOF", status: 200,...}
I can't download this files.
Code from back-end :
try {
res.download( path.join(__dirname, '/PDF/sofianddes.pdf'), (err) => {
if (err) {
console.log(err);
}
});
} catch (err) {}
Someone could help me ?
Thanks