When I use bodyParser it is marked as deprecated. To avoid this I use the following code with express instead of bodyParser.
Notice: the routes must declared finally this is important! Other answers here described the problem well.
const express = require("express");const app = express();const routes = require('./routes/api');app.use(express.json());app.use(express.urlencoded({ extended: false }));// Routes must declared finallyapp.use('/', routes);