Here is the result of my backend API from POSTMAN:
I got two key here, which is jsonand also itemFile
createItem(){
const itemData = this.state;
const selectedFile = this.state;
const formData = new FormData();
formData.append('json', itemData)
formData.append('itemFile', selectedFile)
console.log(formData)
fetch(`http://localhost:9000/api/item/submit`,
{
method: 'post',
body: formData
}).then ((result) => {
let responseJSON = result;
console.log(responseJSON);
});
}
After that, I got the error of Unrecognized token 'object': was expecting ('true', 'false' or 'null')\n at [Source: (String)\"[object Object]\"; line: 1, column: 8]
Is it I need to use JSON.Stringify? but how would I use it in form-data?
