6

I'm sure this is a simple one, but I just can't get chained functions to work in Parse.com's Cloud Code. I know it's possible - so this may be an indictment of my javascript n00bness. ;>

Below is a simple test function-chain that shows how I think it should work - but it doesn't. On response.error events, I seem to get errors, but on success I get:

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

Here are the test functions:

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));
    }

  });
});

.. and here is my initial call to the function, for reference (though I'm sure this is not the problem):

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
1

1 Answer 1

12

You misspelled "success" in your first options object.

Sign up to request clarification or add additional context in comments.

4 Comments

amazingly this same typo was in my actual application code (the error was probably introduced by copying/pasting to this test), so i think you've actually solved it for me.. doing some testing to make sure this solves it for me.. but wow. ;)
that was it.. feeling lame. thanks very much for catching my mistake. ;)
Don't feel lame. These kinds of things happen to the best every now and then
Reporting experiencing the same typo, unbelievable :) After hour of debugging my code finally I decided to go stackoverflow.. to my disappointment, the accepted answer was about typo.. then I checked my code and INDEED in only ONE place I've got "sucess". English - should learn it before JS ;)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.