axios POST
request is hitting the url on the controller but setting null values to my POJO class, when I go through developer tools in chrome, the payload conta
In my case I had to add the boundary to the header like the following:
const form = new FormData();
formData.append(item.name, fs.createReadStream(pathToFile));
const response = await axios({
method: 'post',
url: 'http://www.yourserver.com/upload',
data: form,
headers: {
'content-type': `multipart/form-data; boundary=${form._boundary}`,
},
});
This solution is also useful if you're working with React Native.