getting data from form node
const bodyParser = require("body-parser"); /** bodyParser.urlencoded(options) * Parses the text as URL encoded data (which is how browsers tend to send form data from regular forms set to POST) * and exposes the resulting object (containing the keys and values) on req.body */ app.use(bodyParser.urlencoded({ extended: true })); /**bodyParser.json(options) * Parses the text as JSON and exposes the resulting object on req.body. */ app.use(bodyParser.json()); app.post("/", function (req, res) { console.log(req.body.user.name) });
Source: stackoverflow.com