Failed: Unavailable Read to save the object with a pointer to a new, unsaved object

I have this error and this is my cloud code.

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); 

The answer came back empty, but it is strange that the relation is added successfully when I look at the data browser.

Cannot find a reliable answer or explanation. Please, help.

+4
source share
1 answer

I mentioned here and modified my code. The reason is that I set the creation of an object and adding a relation to 1 save () operation.

 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"); } }); 
+4
source

Source: https://habr.com/ru/post/1480402/


All Articles