javascript - node.js 生成响应时出错。 TypeError : response. json 不是函数

标签 javascript node.js

在我的 Node 应用程序中,我尝试返回一个简单的对象并在控制台中收到此错误:

Error generating response. TypeError: response.json is not a function

我的 messaging.js 文件中的代码:

module.exports = {
    getConfig: function(res) {
        getConfig(res);
    }
};

function getConfig(response) {    
    response.json({
      enabledForAll: false,
      limit: 100
    });
};

main.js

const messaging = require("./modules/messaging.js");
Parse.Cloud.define("getConfig", messaging.getConfig);

有什么建议吗?谢谢

最佳答案

解析FunctionResponse只有两个属性。 成功错误

此外,define 回调的 data 部分有两个函数输入:FunctionRequestFunctionResponse,因此您可能需要类似 function(req,res){ res.success();}

关于javascript - node.js 生成响应时出错。 TypeError : response. json 不是函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52100989/

相关文章:

javascript - 如何防止 Javascript 改变 Selenium 中的页面?如何下载原始页面源代码?

mysql - node-mysql 多个实例失败

javascript - fs.readdir 在函数内部调用时返回 undefined

node.js - 是否可以在单个 node.js 项目中使用两个不同版本的 npm 模块?

mysql连接休息服务

javascript - Vuex:仅当存在商店属性时每 2 秒调度一次函数?

javascript - 无法让 date.toLocaleString() 将时间更改为语言环境

javascript - 如何使用相同的 Restful 后端在两个独立的网络应用程序(javascript)之间进行通信?

javascript - Lodash 将数组转换为对象

javascript - 如何合并 fabrcjs 中的触摸路径?