我的后端登录过程正在nodejs 12.16.1。上运行。代码如下:
router.post("/elogin", async (req, res) => {
try {
if (!req.body.userName || !req.body.password) throw new Error("No match"); //<<==this line causes error and jump to catch
let emp = await Employee.findOne({where: {username, password}});
if (!emp) throw new Error("No match!");
return res.status(200).send(_.pick(emp, ['id', 'cell', 'cell_country', 'name']))
} catch(err) {
return res.status(400).send("Hi Not working right now"); //<<===this return stuck and never come out.
}
});
在调试中,根据在线信息,粘贴在drainQueues
中的bluebird
中的代码是一个承诺库。执行永无止境,并停留在这里。这是正常的return
,我看不到它将如何卡住。有人有主意吗?非常感谢。
前端为React
和fetch
。动作类型无关紧要。 get
也被卡住。
您尝试使用邮递员查看它是否返回。如果存在,则后端代码可能存在问题