Is it possible to send FormData into two API? For example, I have two input elements like
<form id="form">
<input type="text" name="email" ... />
<input type="file" name="files" ... />
</form>
I want to send some of the form fields to one API and the others to another one. The idea is to have a single simple form for the user, and a single submit action, but behind the scenes we have to send the data to different APIs.
From
const formData = new FormData(document.getElementById('form'));
How can I extract the email value and send it to API1, the files need to goto API2:
fetch('API1', { method: 'POST', body: formData has only 'email' })
fetch('API2', { method: 'POST', body: formData has only 'files' })
This is because my API has different endpoints and protocols for files and meta-data, but I don't want the user to have to submit two different forms.