diff --git a/README.md b/README.md index 335743d2..5507cc6e 100644 --- a/README.md +++ b/README.md @@ -65,6 +65,12 @@ The `bodyParser` object exposes various factories to create middlewares. All middlewares will populate the `req.body` property with the parsed body when the `Content-Type` request header matches the `type` option. +**Note** As of v2, `req.body` is left `undefined` when no body is parsed (for +example when the request has neither `Content-Length` nor `Transfer-Encoding`, +or when `Content-Type` does not match). In v1, `req.body` was always initialized +to `{}`. Code that assumes `req.body` is always an object should use optional +chaining (for example `req.body?.username`) or set a default. + The various errors returned by this module are described in the [errors section](#errors).