1

I have this super simple server:

var app = require('express')();
var bodyParser = require('body-parser');

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

app.post('/update', (req, resp) => {
  debugger;
  resp.send();
});

var server = app.listen(3000, function () {
  var host = server.address().address;
  var port = server.address().port;
  console.log('Example app listening at http://%s:%s', host, port);
});

Using postman, I am sending data to the server like this:

Postman screenshot

REPL shows me an empty body when the request is received:

> req.body
{}

I would expect the body to look something like this:

{
  "hello": "world"
}

Am I missing something obvious ? Probably ..

1
  • 1
    I just looked up debugger;. I never knew you could do that in node.js before. Commented May 8, 2015 at 15:45

1 Answer 1

2

By choosing x-form-urlencoded below postman will send the Content-Type header for you, you dont need to specify it again yourself. You can see this by clicking the Preview button. So you're sending a duplicate Content-Type header which seems to trip up body parser.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.