express.bodyParser() is no longer bundled with express. You can install it using npm i body-parser.

Fixing the error

The code below shows how you can include bodyParser, and by extension jsonParser. Then, simply list jsonParser as the second argument in your POST method, and you will no longer have an undefined request body.

const app = express();
var bodyParser = require("body-parser");
var jsonParser = bodyParser.json();

// POST /endpoint expects JSON body'/myendpoint', jsonParser, function (req, res) {
  // Use req.body here