在我的 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
部分有两个函数输入:FunctionRequest
和 FunctionResponse
,因此您可能需要类似 function(req,res){ res.success();}
关于javascript - node.js 生成响应时出错。 TypeError : response. json 不是函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52100989/