出現 參數是 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);