I have the following code in my routes file:
router.post('/submit', function(req, res) {
var email = req.body.email;
console.log(email);
});
I am making a post call from postman with following details: http://localhost:3000/login/submit
params:
email=abcxyz@gmail.com
and headers i have tried both
Content-Type:application/json
and
Content-Type: application/x-www-form-urlencoded
Also, I have body parser separately installed with following in app.js
var bodyParser = require('body-parser');
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
But, The console log for email shows 'undefined'. Why am i not able to grab the post params with req.body.email.