我遇到此错误,这是我的云代码。
var HighScore = Parse.Object.extend("HighScore");
highScore = new HighScore();
highScore.set("totalXp", request.params.totalXp);
highScore.set("regionId", request.params.regionId);
var relation = highScore.relation("userId");
relation.add(request.user);
highScore.save();
response.success(highScore);
响应返回为空,但奇怪的是,当我查看数据浏览器时,关系已成功添加。
无法找到可靠的答案或解释。请帮忙。
答案 0 :(得分:4)
我提到了here,并修改了我的代码。原因是因为我在1 save()操作中放置了创建对象和添加关系。
var HighScore = Parse.Object.extend("HighScore");
highScore = new HighScore();
highScore.set("totalXp", request.params.totalXp);
highScore.set("regionId", request.params.regionId);
highScore.save(null, {
success: function(savedHighScore){
var relation = savedHighScore.relation("userId");
relation.add(request.user);
//relation.add(Parse.User.current());
savedHighScore.save(null, {
success: function(finalHighScore){
response.success(finalHighScore);
},
error: function(finalHighScore, error){
}
});
},
error: function(highScore, error){
console.log("failed to create");
}
});