Express js send pdf file

Viewed 82

how can i delegate PDF file from node-fetch? I tried like that but it is not work

const response = await fetch(...);
const buffer = await response.buffer();
res.contentType('application/pdf');
res.send(buffer);

The output from this example is JSON:

{"0":37,"1":80,"2":68, ....}

Can you help me how to send it as PDF?

Thank you.

1 Answers

I found solution, pretty easy

response.body.pipe(res);
Related