解决node 运行接口 出现 Cannot destructure property `us` of 'undefined' or 'null'.


出现 参数是 undefined or null 

一、检查是否安装 body-parser

      server.js中是否引入 

app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
 
二、如果上面没有问题,请注意是是否 中间件顺序是否有问题
 
 错误:
app.use('/user',router);
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
 
正确:
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
app.use('/user',router);
 
 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM