CNode

关于bodyparser req.body为空的问题,这是什么bug吗,高手请指教

问答
BBingoTrai发布于10 年前最后回复10 年前2 回复4376 浏览0 收藏

我的一个路由中req.body是拿得到前端是数据的,但是其他路由bodyParser全部都是undefined,有谁可以告诉我问题在哪吗?

查看回复

回复 (2)

K
klesh#1·10 年前

bodyParser 有没有放在前面?

G
giscafer#2·10 年前
  app.use(bodyParser.json());
  app.use(bodyParser.urlencoded({ extended: true }))

extended含义: The extended option allows to choose between parsing the URL-encoded data with the querystring library (when false) or the qs library (when true). The “extended” syntax allows for rich objects and arrays to be encoded into the URL-encoded format, allowing for a JSON-like experience with URL-encoded. For more information, please see the qs library.

参与回复
登录后即可参与回复。登录