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

95
Views
no body in fetch put for node express

I cannot get the body correct on the server. If I use content type of json, I get an empty body, if I use urlencoded I get the body but not parsed. Looks like this { { "title": "New Title" }: '' } I would expect to just access a property on the body like so, req.body.title. I'm using latest version of node and express.

Client

function editMovies() {
    //var putMethod = { method: 'PUT', headers: { "Content-Type": "content-type: application/json" } };
    var putMethod = { method: 'PUT', headers: { "Content-Type": "application/x-www-form-urlencoded" } };
    putMethod.body = JSON.stringify({ "title": "New Title" });
    fetch("/api/movies/2", putMethod).then(function (response) {});
}

Server

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

app.put('/api/movies/:id', function (req, res) {
    var id = req.params.id;
    console.log('put called with:' + req.body.title);
});
about 4 years ago · Santiago Gelvez
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!