How to create a post service with formdata?
I sent formdata by Axios. However, the value of 'req.body.title' on the node-express server is empty. So now I am sending fetch in the following format. But I need to upload the file to the server, so I want to send it using formData.
let bodys = 'title=a1&contents=b'
fetch("http://localhost:5000/test", {
method : 'post',
headers : {
'Content-type' : 'application/x-www-form-urlencoded; charset=UTF-8'
},
body: bodys
})
.then(function(response){
console.log('Request Succeded ', response);
})
.catch(function (error){
console.log('Failed ', error)
})
I wrote new data using append with new FormData(), I checked that FormData contains a value on React. However, the node-express server did not enter the body.
please let me know what to do...