Unfortunately I get an empty body: {}
in the request object, when I POST
something to my api via Insomnia
(configuration Form Form URL Encoded
Header Content-Type: application/x-www-form-urlencoded
):
Here is my express code:
const express = require('express');
const app = express();
app.use(express.json());
app.post('/api/', function(req, res) {
test = req.body.test;
console.log(req);
console.log(test);
res.send("Hallo");
});
const port = 4000;
app.listen(port, () => console.log(`Listening on port ${port}...`));
What am I doing wrong? And also what would I have to change in my code if I'd configure Insomnia to Form as JSON
, Header Content-Type: application/json
?