Javascript 失败:未捕获尝试使用指向新的未保存对象的指针保存对象
我有这个错误,这是我的云代码Javascript 失败:未捕获尝试使用指向新的未保存对象的指针保存对象,javascript,cloud,parse-platform,Javascript,Cloud,Parse Platform,我有这个错误,这是我的云代码 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
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);
响应返回为空,但奇怪的是,当我查看数据浏览器时,关系添加成功
找不到可靠的答案或解释。请帮忙。我参考了,并修改了我的代码。原因是我将创建对象和添加关系放在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");
}
});