我确信这是一个简单的,但我无法在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
答案 0 :(得分:12)
您在第一个选项对象中拼错了“成功”。