Я хочу отправить данные и файл, используя данные формы в почтальоне, чтобы прочитать их на сервере Node JS,
, но я получаю пустое тело {},
var app = express();
var bodyParser = require('body-parser');
// parse application/x-www-form-urlencoded
app.use(bodyParser.urlencoded({ extended: false }));
// parse application/json
app.use(bodyParser.json());
var storage = multer.diskStorage({
destination: function (req, file, cb) {
cb(null, "dir")
},
filename: function (req, file, cb) {
cb(null, "filename")
}
});
var upload = multer({ storage: storage }).single('image');
app.post("/url", function (req, res) {
res.setHeader('Content-Type', 'application/json');
upload(req, res, function (err) {
console.log(req.body)
});
});
Как я могу одновременно читать мои данные и файл?
спасибо.
Версия узла: v12.16.1
NPM версия 6.13.4
npm multer: "^ 1.4.2 «