I know there are thousands of questions like this, but none of the solutions works for me:
- Change to Fetch Api
- Use format {uri: ..., type: ..., name: ...} in formData
I also have noticed that I can't send the formData directly in the "data" axios's property (when using Axios({...})), because the formData object has a property call "._parts", so I have to do:
let formData = new FormData()
formData('image', {uri: imagePicker.uri, name: 'some_name.jpeg', type: 'image/jpeg'})
formData('data', {name: 'Andrea'})
let xmlHttp = await Axios({
method: 'POST',
url: `url...`,
data: formData._parts,
headers: {
Authorization: `Bearer ${_token}`,
'Content-Type': 'multipart/form-data',
},
} ).catch(error => {
throw error
});
Then, in Node, I get this:
req.body -> [Object: null prototype] {}
req.file -> undefined
upload.single("image"), in router.post and multerS3.
Some idea? Thank you