6

我确信这是一个简单的方法,但我无法让链式函数在 Parse.com 的 Cloud Code 中工作。我知道这是可能的——所以这可能是对我的 javascript n00bness 的控诉。;>

下面是一个简单的测试函数链,它显示了我认为它应该如何工作 - 但事实并非如此。在response.error事件中,我似乎得到了错误,但在成功时我得到:

{"code":141,"error":"success/error was not called"}

以下是测试功能:

Parse.Cloud.define("initialFunction", function(request, response) {

  var player = request.params.player;

  Parse.Cloud.run("chainedFunction",{ player: player.id },{
    sucess: function(results) {

      response.success(results);

    },
    error: function(results, error) {
      response.error(errorMessageMaker("running chained function",error));
    }
  });

});

Parse.Cloud.define("chainedFunction", function(request, response) {

  var player = Parse.Object.extend("User");
  var findPlayer = new Parse.Query(player);
  findPlayer.get(request.params.player, {

    success: function(player) {
      var games = player.relation("games");
      games.query().find({

        success: function(games) {

          response.success(games);

        },
        error: function(players, error) {
          response.error(errorMessageMaker("finding games",error));
        }

      });
    },
    error: function(player,error) {
      response.error(errorMessageMaker("finding player",error));
    }

  });
});

..这是我对该函数的初始调用,以供参考(尽管我确信这不是问题):

curl -X POST \
   -H "X-Parse-Application-Id: <id>" \
   -H "X-Parse-REST-API-Key: <id>" \
   -H "Content-Type: application/json" \
   -d '{"player":"<id>"}' \
   https://api.parse.com/1/functions/initialFunction
4

1 回答 1

12

您在第一个选项对象中拼错了“成功”。

于 2012-10-03T02:15:48.540 回答