【发布时间】:2020-10-29 01:16:16
【问题描述】:
我正在尝试使用 ExpressJS 在 POST 方法上获取 req.body
但我总是可以得到空的 json 对象 ({})。
app.use(bodyParser.urlencoded({extended: true}));
app.use(bodyParser.json());
app.post("/", (req, res) => {
console.log(req.body) // {}
res.send(200, req.body); // {}
});
谁能帮帮我?
我正在使用: “正文解析器”:“^1.19.0”, "快递": "^4.17.1",
【问题讨论】:
-
仅供参考,
app.use(bodyParse.json());拼写错误,应为app.use(bodyParser.json());
标签: express post body-parser