我正在尝试运行我的 Parse 云代码作业,但它一直给我一个错误,指出失败:成功/错误未调用
,尽管事实上这两个调用都在函数结束。我是否以一种他们永远不会被调用的方式进行设置?
Parse.Cloud.job("mcItemCount", function(request, response) {
// Query all users
var usersQuery = new Parse.Query(Parse.User);
// For each user in the DB...
return usersQuery.each(function(user) {
//Query all matchCenterItems associated with them
var matchCenterItem = Parse.Object.extend("matchCenterItem");
var mcItemQuery = new Parse.Query(matchCenterItem);
mcItemQuery.equalTo('parent', user);
// Set the numberOfItems property equal to the # of matchCenterItems they have
mcItemQuery.find().then(function(results) {
var numberOfItems = results.length;
user.set("numberOfItems", numberOfItems);
});
}.then(function() {
// Set the job's success status
response.success("mcItemsCount completed successfully.");
status.success("mcItemsCount completed successfully.");
}, function(error) {
// Set the job's error status
response.error('DAMN IT MAN');
status.error("mcItemsCount FAAAAIIILLED");
});
});
最佳答案
您似乎尚未定义状态
。将函数定义中的 response
参数替换为 status
,然后删除 response.success
和 response.error
来电:
Parse.Cloud.job("mcItemCount", function(request, status) {
// Query all users
var usersQuery = new Parse.Query(Parse.User);
// For each user in the DB...
return usersQuery.each(function(user) {
// ...
}.then(function() {
// Set the job's success status
status.success("mcItemsCount completed successfully.");
}, function(error) {
// Set the job's error status
status.error("mcItemsCount FAAAAIIILLED");
});
});
关于javascript - 尽管两个调用都存在,但失败并显示 : success/error was not called,,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32321410/