随着express升级,bodyParser从express中被分离了出来,因此,在使用express新版本的时候,需要npm install body-parser 来安装bodyParser。

  1. 在app.js中要引入bodyParser。

    var bodyParser = require(‘body-parser‘);

  2. 其次,需要在app.js中use bodyParser。

    app.use(bodyParser());

  3. 最后,需要给bodyParser提供参数。

    ‘Content-Type‘: ‘application/x-www-form-urlencoded‘ 

    对于bodyParser的参数,根据需要解析的文件类型来进行设置,参数类型有很多种,可以查看具体文献。

相关文章:

  • 2021-12-23
  • 2021-09-21
  • 2021-05-26
  • 2021-11-10
  • 2021-05-22
  • 2022-12-23
  • 2021-10-02
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-02-20
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案