Skip to content

Instantly share code, notes, and snippets.

@rlataguerra
Created August 7, 2023 20:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rlataguerra/1da36eacc596060c386df0a6695dd438 to your computer and use it in GitHub Desktop.
Save rlataguerra/1da36eacc596060c386df0a6695dd438 to your computer and use it in GitHub Desktop.
Doppio.sh - Fetch from node.js
const fetch = import('node-fetch');
const myHeaders = {
"Authorization": "Bearer xxxxxxxxxxxxxxx",
"Content-Type": "application/json"
};
const raw = JSON.stringify({
"page": {
"goto": {
"url": "https://google.com"
}
}
});
const requestOptions = {
method: 'POST',
headers: myHeaders,
body: raw,
};
let pdfBuffer = null;
fetch
.then(({ default: fetch }) => fetch("https://api.doppio.sh/v1/render/pdf/direct", requestOptions))
.then(response => response.arrayBuffer())
.then(buffer => {
pdfBuffer = buffer;
console.log(pdfBuffer);
})
.catch(error => console.log('error', error));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment