so as the title explains, I am trying to send both JSON data and an array of files using Axios to my Flask BE server. I am not sure where the problem lies, whether it is in FE or BE, but I cannot seem to send the files. I am trying to send it in a FormData object but if I try to send the array of files together, it shows:
[object File, object File, ...]
When I send them individually, it sends as binary which is what I want. But I cannot send binary data in the array.
If possible, please let me know how I can send it and read it in my Flask server in BE.
EDIT:
let formData = new FormData();
formData.append('data', JSON.stringify(data));
const files = data?.additional_document;
if (Array.isArray(files )) {
const arrayKey = `additionalFiles`;
files.forEach(v => {
formData.append(arrayKey, v);
});
}
dispatch(apiCallToBackEnd(formData, (res) => getPDF(res)));