React前端未从Reactjs + Nodejs应用程序中的nodejs后端接收到回报

问题描述 投票:0回答:1

我的后端登录过程正在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,我看不到它将如何卡住。有人有主意吗?非常感谢。

前端为Reactfetch。动作类型无关紧要。 get也被卡住。

enter image description here

node.js reactjs bluebird
1个回答
0
投票

您尝试使用邮递员查看它是否返回。如果存在,则后端代码可能存在问题

© www.soinside.com 2019 - 2024. All rights reserved.