主页正常显示,但是登录时报错。

来源:7-18 联调演示与总结

珍妮玛一黛金

2022-03-09

登录功能不能使用,发送请求时没有反应,控制台显示

Status Code:

504 Gateway Time-out

终端报错内容是:

(node:15748) UnhandledPromiseRejectionWarning: TypeError: Cannot destructure property `username` of 'undefined' or 'null'.

    at handleUserRouter (F:\VScode项目库\nodejs\blog-1\src\router\user.js:18:40)

    at get.then.then.postData (F:\VScode项目库\nodejs\blog-1\app.js:144:24)

    at process._tickCallback (internal/process/next_tick.js:68:7)

(node:15748) 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:15748) [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回答

双越

2022-03-09

根据错误提示,找一下这个 user.js 18行是什么代码?截图给我看下

//img.mukewang.com/szimg/6228af6309bcdd6d15320372.jpg

0
0

珍妮玛一黛金

提问者

2022-03-09

登录模块//img.mukewang.com/szimg/6228b0a109a66fd607650497.jpg

0
3
双越
回复
珍妮玛一黛金
有两种可能。第一,请求没有 request body ,没传递给服务器任何信息;第二,你 nodejs 中对 req.body 的赋值写的有问题。你可以先从第二条查起。
2022-03-10
共3条回复

Node.js+Express+Koa2+Nest.js 开发服务端

从入门到实战,一站式掌握 Node.js+Express+Koa2

4132 学习 · 2024 问题

查看课程