I am trying to send data to express from react. I have array of images which I have to send, but since I cannot send a single image as a test I will have to clearify what is happening. I set hardcoded image just for testing, since I have tried almost everything without success I want to do the simplest upload possible and I get null in the server side.
React
const formData = new FormData();
formData.append('files', cartImg);
axios
.post(
`http://localhost:8800/imgUpload`,
{ formData },
{
headers: { 'Content-Type': 'multipart/form-data' },
}
)
.then((res) => setMessage(res.data));
Express
app.post('/imgUpload', (req, res) => {
console.log(req.files);
});