Unable to send data from react to express server

I am trying to send data from react to express server.

React code:

const imageRenderer = async () => {
  const res = await axios({
    method: "post",
    url: "http://localhost:8080/previewRender",
    data: selectedFile.filePaths,


Express code:

app.post("/previewRender", (req, res) => {
  var fileLocation = req.body;

However in console the filelocation is shown as undefined. selectedFile.filePaths is of type object. Can’t I send object to express?


Did you use app.use(express.json()) in your app.js?