I'm looking at trying to write a JavaScript function to post data back to my API server with Axios. However, I need the file to be in the Files
field of the request and not in the body.
let formData = new FormData();
formData.append("files", acceptedFiles[0], 'image.jpeg');
let url = "https://webhook.site/39e22a22-7fe2-45e6-bf7b-ba406ea550cc"
let resp = await axios.post(url, formData,{
headers: { 'content-type': 'multipart/form-data' }
});
Raw Content Received by webhook.site
------WebKitFormBoundaryu1izASXZlBjTDNFk
Content-Disposition: form-data; name="files"; filename="image.jpeg"
Content-Type: image/jpeg
But when I do it with something like Insomnia API client. I get no body and no content. But the file is in the Files
part of the request.
How do I achieve the what Insomnia is doing?
Santiago Trujillo