var express = require('express');
var app = express();
var PORT = 3000;
const bodyParser = require('body-parser')
app.use(bodyParser.json())
app.use(bodyParser.urlencoded({extended: true}));
app.post('/', function (req, res) {
console.log(req.body);
console.log(req.body.username);
res.end();
});
app.listen(PORT, function(err){
if (err) console.log(err);
console.log("Server listening on PORT", PORT);
});
Test by postman: Post: http://localhost:3000 { "username":"userabc", "password":"passwd1234" }
But, the result is: {} undefined