Created
February 17, 2021 21:27
-
-
Save travist/d68bca20642470f475dd5b43e3ffdaa0 to your computer and use it in GitHub Desktop.
Proxy a Form.io PDF Submission
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 = require('node-fetch'); | |
const FormData = require('form-data'); | |
// Refer to https://apidocs.form.io/#0e4214b1-4e35-f22c-3a0c-0a5e01c62126 to get the right url here. | |
fetch('https://api.form.io/project/[PROJECT_ID]/form/[FORM_ID]/submission/[SUBMISSION_ID]/download?token=[DOWNLOAD_TOKEN]', { | |
method: 'GET' | |
}).then((response) => { | |
const form = new FormData(); | |
form.append('file', response.body, { filename : 'submission.pdf' }); | |
fetch('https://httpbin.org/post', { | |
method: 'POST', | |
body: form | |
}) | |
.then((resp) => resp.json()) | |
.then((response) => console.log(JSON.stringify(response, null, 2))); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment