我正在尝试让我的Parse云代码作业运行,但它不断给我一个错误,说明Failed with: success/error was not called
,尽管这两个调用都在函数的末尾。我是否以一种他们永远不会被召唤的方式进行设置?
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");
});
});
答案 0 :(得分:3)
似乎您还没有定义status
。将功能定义中的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");
});
});