javascript - GMT uncaughtException:无法读取未定义节点 js 的属性“发送”
问题描述
我的控制器获取响应值,但是当我尝试发送响应时,它会抛出错误。数据的 console.log 给出了 json 值。
GMT uncaughtException:无法读取未定义的属性“发送”
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
了两次变量。所以对 express res 对象的引用丢失了。
推荐阅读
- uwp - 将内容文本置于教学提示内的中心
- c# - 通过 GetType 投射到对象?
- java - 将嵌套的 Json 解析为表(包含嵌套属性的所有排列)
- javascript - 使用 ionic 4 中的 FormData 将捕获视频上传到服务器
- php - 我在使用 SSE-C 加密技术解密我的文件时遇到 aws s3 问题
- python - TensorFlow 神经网络不学习
- vb.net - 我可以为 VB.NET 应用程序使用外部硬件吗,例如:指纹传感器
- sql - PostgreSQL:在边界框内显示行程
- javascript - 带有动画表情符号的 Discord 机器人
- python - 尝试使用 docker 构建 sa-logic 应用程序时出现错误“为正则表达式构建轮子失败”