How to use Browserless PDF API from expressjs? #4140
-
Beta Was this translation helpful? Give feedback.
Answered by
perevezencev
Jun 27, 2024
Replies: 1 comment
-
I needed to add the app.get("/api/pdf", async (request, response) => {
try {
const { data } = await axios.post(
"http://localhost:3001/pdf",
{
url: "https://www.google.com/",
},
{
responseType: "arraybuffer",
},
)
response.setHeader("content-type", "application/pdf")
response.contentType("application/pdf")
response.send(Buffer.from(data, "binary"))
} catch (error) {
console.log(error.message)
}
}) |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
joelgriffith
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I needed to add the
responseType: "arraybuffer"
to theaxios.post
config object: