I have an issue with POST
requests, that it always returns an empty object if I choose form-data
as a body type, it works only when I choose raw
, but I need to send form-data
to send some files.
Here's my index.js
file:
const express = require('express');
const app = express();
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
app.post('/', (req, res) => {
res.json(req.body);
});
app.listen(5000, () => console.log('Up & Running'));
I found already some solutions like this, and more, but none of them worked out for me.
here's a screenshot from the postman.
as you can see, it returns an empty object here, regardless of ant data that I've sent.
however, if I choose body raw
it works fine.
Has anybody solved this problem before?