简体   繁体   English

如何重新添加/包括从connect中删除的express / connect json()和urlencoded()解析器?

[英]How to re-add/include the express/connect json() and urlencoded() parsers that were removed from connect?

So the connect guys removed my urlencoder and json parser. 因此,连接人员删除了我的urlencoder和json解析器。 Absolutely nothing wrong with those middlewares and I'd like to continue using them to send emails and retrieve form input data. 这些中间件绝对没有错,我想继续使用它们来发送电子邮件和检索表单输入数据。

Note: I am not dealing with any type or form of file uploading. 注意:我不处理任何类型或形式的文件上传。 Also, I tried going over to the link the error message provides when I try and use the express/connect.urlencoded() and express/connect.json() and I ended up wasting two hours clicking from github to github. 另外,我尝试转到错误消息提供的链接,当我尝试使用express / connect.urlencoded()和express / connect.json()时,我浪费了两个小时从github单击到github。 I don't want an over bloated file uploader. 我不要一个过大的文件上传器。 Just my simple form parser, without the file upload. 只是我的简单表单解析器,没有文件上传。 Just doesn't make sense to remove the two working middleware because of one faulty middleware. 由于一个错误的中间件,删除两个工作的中间件只是没有意义。

In Express 4, all bundled middleware (except static) has been removed - however, you can still install it via npm: 在Express 4中,已删除所有捆绑的中间件(静态除外)-但是,您仍然可以通过npm安装它:

npm install --save body-parser

and require it in your app: 并在您的应用中要求它:

var bodyParser = require('body-parser');
// ...
app.use(bodyParser());

Consult this article for information about migrating from Express 3 to 4: 请参阅本文,以获取有关从Express 3迁移到4的信息:

http://scotch.io/bar-talk/expressjs-4-0-new-features-and-upgrading-from-3-0 http://scotch.io/bar-talk/expressjs-4-0-new-features-and-upgrading-from-3-0

It has a nice table if you scroll down a bit where it lists what the bundled middleware was called in Express 3, and the corresponding name of the package if you want to use it in Express 4. 如果向下滚动一点,它会列出一个不错的表,该表列出了Express 3中捆绑的中间件的名称,以及要在Express 4中使用的包的相应名称。

There's also the official Express 4 migration guide here: 这里还有官方的Express 4迁移指南:

https://github.com/visionmedia/express/wiki/Migrating-from-3.x-to-4.x https://github.com/visionmedia/express/wiki/Migrating-from-3.x-to-4.x

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM