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

时间:2018-08-30 15:47:47

标签: javascript node.js

在我的节点应用中,我试图返回一个简单的对象,并在控制台中得到此错误:

  

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

我的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);

有什么建议吗?谢谢

1 个答案:

答案 0 :(得分:1)

解析FunctionResponse仅具有两个属性。 applysuccess

此外,error回调的data部分有两个函数输入defineFunctionRequest,因此您可能需要类似FunctionResponse的东西