examples under "route-specific" are incorrect
azhao12345 opened this issue · comments
This part of the documentation is incorrect. As mentioned in the earlier documentation, the body property is set to an empty object when no body parser matches or the payload is no good. This means that req.body should never be a falsey value
// POST /login gets urlencoded bodies
app.post('/login', urlencodedParser, function (req, res) {
if (!req.body) return res.sendStatus(400)
res.send('welcome, ' + req.body.username)
})
$ curl -X POST localhost:3000/login
welcome, undefined