title: Parse.com Cloud Code: Chaining functions?
body: <p>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. ;></p>
  
  <p>Below is a simple test function-chain that shows how I think it should work - but it doesn't. On <code>response.error</code> events, I seem to get errors, but on success I get:</p>
  
  <p><code>{"code":141,"error":"success/error was not called"}</code></p>
  
  <p>Here are the test functions:</p>
  
  <pre><code>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));
      }
  
    });
  });
  </code></pre>
  
  <p>.. and here is my initial call to the function, for reference (though I'm sure this is not the problem):</p>
  
  <pre><code>curl -X POST \
     -H "X-Parse-Application-Id: &lt;id&gt;" \
     -H "X-Parse-REST-API-Key: &lt;id&gt;" \
     -H "Content-Type: application/json" \
     -d '{"player":"&lt;id&gt;"}' \
     https://api.parse.com/1/functions/initialFunction
  </code></pre>