首页 > 解决方案 > GMT uncaughtException:无法读取未定义节点 js 的属性“发送”

问题描述

我的控制器获取响应值,但是当我尝试发送响应时,它会抛出错误。数据的 console.log 给出了 json 值。

GMT uncaughtException:无法读取未定义的属性“发送”

export const countController = {  
    countFetch: async (req, res) => {   
        await count((data, res) => {   
            res.send(data);
        })
    }
}

请告知我在哪里做错了。谢谢

标签: javascriptmysqlnode.jsapiresponse

解决方案


更改如下代码片段即可


export const countController = {  
    countFetch: async (req, res) => {   
        await count((data, countRes) => {   
            res.send(data);
        })
    }
}

您已经定义res了两次变量。所以对 express res 对象的引用丢失了。


推荐阅读