很简单的代码 但是一直出错 求指点
var express = require('express');
var router = express.Router();
/* GET home page. */
router.post('/login', function(req, res, next) {
const { username, password } = res.body
res.json({
errno: 0,
data: {
username,
password
}
})
});
module.exports = router;
var indexRouter = require('./routes/index');
var usersRouter = require('./routes/users');
const blogRouter = require('./routes/blog');
const userRouter = require('./routes/user');
var app = express();
// view engine setup
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'jade');
app.use(logger('dev'));
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));
app.use('/', indexRouter);
app.use('/users', usersRouter);
app.use('/api/blog', blogRouter);
app.use('/api/user', userRouter);
报错信息如下
TypeError: Cannot destructure property username
of ‘undefined’ or ‘null’.