request-promise download pdf file
Add encoding: null
to your request options:
const optionsStart = {
uri: url,
method: "GET",
encoding: null,
headers: {
"Content-type": "application/pdf"
}
};
Then, turn the response into a Buffer (if necessary):
const buffer = Buffer.from(response);
Add encoding: 'binary' to your request options:
const optionsStart = {
uri: url,
method: "GET",
encoding: "binary", // it also works with encoding: null
headers: {
"Content-type": "application/pdf"
}
};