req.body is undefined
var bodyParser = require('body-parser') var app = express() // parse application/x-www-form-urlencoded app.use(bodyParser.urlencoded({ extended: false })) // parse application/json app.use(bodyParser.json())
Here is what the above code is Doing:
1. We’re requiring the express module and assigning it to a variable called express.
2. We’re creating an instance of express and assigning it to a variable called app.
3. We’re requiring the body-parser module and assigning it to a variable called bodyParser.
4. We’re telling our app to use the bodyParser module.