Sign In Register

How can we help you today?

Start a new topic

Mistakes in Game Data service documentation

There is a mistake on the page , under the section "Searching with Cloud Code"

After the sentence "To retrieve player details in the future, use the function below anywhere in your Cloud Code:", there is the following code:

//Create entry and get its data object
var API = Spark.getGameDataService();

//Create a query, in this example we want to find a user with a unique userName
var query = API.S("userName").eq("exampleName");

//Run query on userDetails collection
var resultOBJ = API.queryItems("userDetails", query);

//If our query is successful
if(resultOBJ.error() != null){
        //Get playerID which is set as the entry ID and load player
} else{
    //If our query comes back without results output error
    Spark.setScriptError("ERROR", "Player might not exist, please check userName again")
The way this code is written, it will only try to iterate through the resultOBJ if there is an error. If there is no error, it will return the error message.

The if statement should read
if(resultOBJ.error() === null){


Login to post a comment