解決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