一到这个登陆 就会显示 postman里一直在sending request ,然后报错 handleUserRouter is not a function
来源:5-11 开发路由(删除博客路由和登录路由)
慕雪0323865
2020-08-20
const handleUserRouter = (req, res) => {
const method = req.method
//登陆
if (method === 'POST' && req.path === '/api/user/login') {
const { username, password } = req.body
const result = loginCheck(username, password)
if (result) {
return new SuccessModel()
}
return ErrorModel('登陆失败')
}
}
报错是 UnhandledPromiseRejectionWarning: TypeError: handleUserRouter is not a function
at /Users/louis/Desktop/blog/app.js:60:26
at processTicksAndRejections (internal/process/task_queues.js:93:5)
(node:9933) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:9933) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
2回答
-
好好学习天天向上喽
2020-12-04
return ErrorModel('登陆失败') => return new ErrorModel('登陆失败')
10 -
双越
2020-08-21
第一,在 app.js 中打印一下 handleUserRouter 是个啥?
第二,把 /Users/louis/Desktop/blog/app.js:60:26 附近的代码截图出来看看,是这里报的错
00
相似问题