Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

183
Views
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,
  });
console.log(res.data);

};

Express code:

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

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

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Add this in app.js (app.js) or your root file of the app to post req

app.use(express.json());

app.use(express.urlencoded({ extended: false }));

Put this middleware in app.js above your routes...

about 4 years ago · Juan Pablo Isaza Report

0

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

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!