GMT 未捕获异常:无法读取未定义节点 js 的 属性 'send'
GMT uncaughtException: Cannot read property 'send' of undefined Node js
我的控制器获得了响应值,但是当我尝试发送响应时,它抛出了错误。 console.log 数据给出 json 值。
GMT uncaughtException: Cannot read property 'send' of undefined
export const countController = {
countFetch: async (req, res) => {
await count((data, res) => {
res.send(data);
})
}
}
请指教我哪里做错了。谢谢
像下面这样更改代码片段就可以了
export const countController = {
countFetch: async (req, res) => {
await count((data, countRes) => {
res.send(data);
})
}
}
您已定义 res
变量两次。所以对表达 res 对象的引用丢失了。
我的控制器获得了响应值,但是当我尝试发送响应时,它抛出了错误。 console.log 数据给出 json 值。
GMT uncaughtException: Cannot read property 'send' of undefined
export const countController = {
countFetch: async (req, res) => {
await count((data, res) => {
res.send(data);
})
}
}
请指教我哪里做错了。谢谢
像下面这样更改代码片段就可以了
export const countController = {
countFetch: async (req, res) => {
await count((data, countRes) => {
res.send(data);
})
}
}
您已定义 res
变量两次。所以对表达 res 对象的引用丢失了。