Parse.com Cloud Code: Chaining functions?

javascript, parse-platform

Solution

You misspelled "success" in your first options object.

Problem

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 ```

Original source