I am building a server using sails which is supposed to pull the pdf content from an endpoint and send it in the response. How do I do this This is what I have tried so far:
fn: async function (inputs, exits) {
const downloadLink = this.req.param('link');
const pdf = (await axios.get(downloadLink, { responseType: 'blob'
})).data
if (!downloadLink || !pdf) {
throw 'not found';
}
this.res.attachment('abc').send(pdf);
return exits.success();
}
This, however, does not seem to work. I have pdf.js installed in my chrome which displays pdf content. When I try to run the code above, it tries to open a file but ends up showing the error "invalid pdf content"