Reputation: 57
I have an api to upload some documents, I create a FormDdata variable with 2 keys: documentInfo (an object contain user info) and files(contain document info. I try with Postman and it success with content-type of documentInfo property is 'application/json', but i can not do it on my code
const formdata = new FormData()
formdata.append('documentInfo', documentInfo)
formdata.append('files', file)
{
"method": "POST",
"data": formdata,
"timeout": 30000,
"headers": {
"Content-Type": "multipart/form-data",
},
"url": "url"
}
Upvotes: 2
Views: 653
Reputation: 88
You need to pass file param correctly. It's a bit different from Postman
formData.append('files', {
uri: file.uri,
type: file.type,
name: `abc.png`,
})
Upvotes: 2