不推荐使用BodyParser [英] BodyParser is deprecated

查看:77
本文介绍了不推荐使用BodyParser的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如图所示,BodyParser现在已被弃用,如何更正bodyParser语法或语句以删除直通?

As the image shown, BodyParser now is deprecated, how to correct the bodyParser syntax or statement to remove the line-through?

推荐答案

如果您使用的是Express 4.16+,则不必再导入 body-parser .您可以像这样:

If you are using Express 4.16+ you don't have to import body-parser anymore. You can do it just like this:

app.use(express.urlencoded({extended: true}));
app.use(express.json()) // To parse the incoming requests with JSON payloads

这篇关于不推荐使用BodyParser的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆