I have the following Typescript code:
import express = require('express');
const app: express.Application = express();
const port: number = 3000;
app.listen(port, () => {
console.log("Server started on port" + port);
app.use(bodyParser.urlencoded({ extended: true }));
})
app.post('*', (req, res) => {
console.log(req.body);
});
For some reason req.body
is always undefined
instead of getting the key-value pairs sent via postman. Adding app.use(bodyParser.urlencoded({ extended: true }));
only changes the body from undefined
to {}
.
What could be the issue in this case?