javascript - 尽管两个调用都存在,但失败并显示 : success/error was not called,

标签 javascript parse-platform

我正在尝试运行我的 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.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");
    });
});

关于javascript - 尽管两个调用都存在,但失败并显示 : success/error was not called,,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32321410/

相关文章:

javascript - 如何在 MS Dynamics CRM Online 中单击按钮重定向到任何 Web 资源?

ios - 解析从 Int 到 String 的转换不起作用

ios - 从 Parse.com 查询数组到数组

javascript - 如何将日期格式 12/12/2019 转换为 12-12-2019

javascript - 如何创建 Pixi.js 烟雾面具?

javascript - 使用 Mod 运算符。我写了一个脚本来读取一个整数并显示是奇数还是偶数

javascript - jquery切换不同浏览器

ios - 解析 - 检查用户是否存在

iphone - UISearch 不显示结果

swift - 解析与 swift 的集成