Created
August 7, 2023 20:56
-
-
Save rlataguerra/1da36eacc596060c386df0a6695dd438 to your computer and use it in GitHub Desktop.
Doppio.sh - Fetch from node.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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