'Not able to send files data from front-end (react.js) to back-end (node)

I have an application that stores to its state files' content, whether images, audio or both, as shown here with the mediaAudio object key:

enter image description here

In my react.js code, I make my post as such:

   var bodyFormData = new FormData();
    bodyFormData.append('data', formData);

    axios({
      method: "post",
      url: 'http://localhost:5000/post-entry',
      data: bodyFormData,
      headers: { "Content-Type": "multipart/form-data" },
    })
    .then((response) => {
      console.log(response);
    })
    .catch((response) => {
      console.log(response);
    });

In my node.js code, I retrieve my data as such:

app.post('/post-entry', (req, res) => {
  let data = req.body.data;
  console.log(data);
});

However, I'm not able to get the data being logged, it returns undefined.

What is happening? Thanks



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source