I am trying to send a json file to an api with an image file included. The following is the code:
let newUploaded = [...uploaded];
for (var i = 0; i < e.target.files.length; i++) {
newUploaded.push({
url: URL.createObjectURL(e.target.files[i]),
file: e.target.files[i],
})
}
setUploaded(newUploaded);
While seeing the request in the network tab, the following is displayed:
[{"url":"blob:http://localhost:3000/st8q1wgest","file":{}}]
As you can see, the file value is empty. Data is sent using form data.
I need to be able to include the file in the request so I can access it in an API.