BodyParser 已弃用 [英] BodyParser is deprecated

查看:48
本文介绍了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天全站免登陆