why is 'body' empty in nodejs express post request?
As you are using POSTMAN to be able to access request body via req.body
when you are using the buildin express.json
middleware you will have to ensure that are send the request Body using RAW
type and set the type of the body as JSON
like in the image shown bellow
If the body type is set to something else (Text, JavScript, HTML, XML) You'll still getting an empty body. Only when it's set as JSON
you will get req.body
filled with data which you sent as part of you request body