为了账号安全,请及时绑定邮箱和手机立即绑定

为什么安装了body-parser还无法获得name,deadline,content这三个变量?

总报错说:

TypeError: Cannot destructure property `name` of 'undefined' or 'null'.

正在回答

1 回答

// 按照官方文档
// 1. npm install body-parser -S
// 2. 引入  在app.js中
const bodyParser = require('body-parser');
// 3. 放入中间件
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended: true});

// 4.发送请求的时候 可以使用 urlencoded 格式
// 5.如果发送的是json,那么需要加入header 
Content-Type: application/json


0 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消

为什么安装了body-parser还无法获得name,deadline,content这三个变量?

我要回答 关注问题
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号