解决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);
 
 
posted @ 2020-06-16 14:31  红妆  阅读(5140)  评论(0编辑  收藏  举报