Unverified Commit daa7f821 authored by Connor Mcgarty-Wood's avatar Connor Mcgarty-Wood Committed by GitHub

Docs: Add req.body to custom express server example (#12211)

parent 6a8aef71
...@@ -36,3 +36,25 @@ npm run dev ...@@ -36,3 +36,25 @@ npm run dev
yarn yarn
yarn dev yarn dev
``` ```
### Populate body property
Without the use of the body-parser package `req.body` will return undefined. To get express to populate `req.body` you need to install the body parser package and call the package within server.js.
Install the package:
```bash
npm install body-parser
```
Use the package within server.js:
```bash
const bodyParser = require('body-parser');
app.prepare().then(() => {
const server = express();
server.use(bodyParser.urlencoded({ extended: true }))
server.use(bodyParser.json())
})
```
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment