Render to fetch request? #2365
Answered
by
coskuncakir
noconsulate
asked this question in
Q&A
-
I want my react app to render a PDF and then send it off via a fetch request. Is this possible with react-pdf and can someone point me in the right direction? Thanks |
Beta Was this translation helpful? Give feedback.
Answered by
coskuncakir
Jul 19, 2023
Replies: 2 comments
-
hey @noconsulate, i think you could send the blob data off via a fetch req, so it could be something like this?: const blob = pdf(<MyDocument />).toBlob();
blob.then((blob) => {
fetch('https://endpoint', {
method: 'POST',
body: blob,
})
.then((response) => response.json())
.then((data) => console.log(data))
.catch((error) => console.log(error));
}); also, you can check here: https://react-pdf.org/advanced#on-the-fly-rendering |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
noconsulate
-
Wow, this is great. Just what I needed to put me in the right path. Thanks!
…On Wed, Jul 19, 2023 at 8:27 AM Coskun Cakir ***@***.***> wrote:
hey @noconsulate <https://github.com/noconsulate>, i think you could send
the blob data off via a fetch req, so it could be something like this?:
const blob = pdf(<MyDocument />).toBlob();
blob.then((blob) => {
fetch('https://endpoint', {
method: 'POST',
body: blob,
})
.then((response) => response.json())
.then((data) => console.log(data))
.catch((error) => console.log(error));});
also, you can check here:
https://react-pdf.org/advanced#on-the-fly-rendering
—
Reply to this email directly, view it on GitHub
<#2365 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ALISQCYGBD4T6ZVC3WSZPWDXQ7VGZANCNFSM6AAAAAA2PDRWZA>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
hey @noconsulate, i think you could send the blob data off via a fetch req, so it could be something like this?:
also, you can check here: https://react-pdf.org/advanced#on-the-fly-rendering