失败:success/error未被调用,尽管两个调用都在那里

Failed with: success/error was not called, despite both calls being there

本文关键字:调用 在那里 两个 success error 失败      更新时间:2023-09-26

我试图让我的解析云代码作业运行,但它一直给我一个错误说明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");
    });
});

您似乎还没有定义status。将函数定义中的response参数替换为status,然后删除response.successresponse.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");
    });
});