question

chju1020 avatar image
chju1020 asked

Am I doing wrong with GetLeaderboard in CloudScript?

in cloudscript, I wrote below code.

handlers.CalcUserRank = function (args, context) {
var result = server.GetLeaderboard({
StatisticName: "TotalGainedPoint",
StartPosition: 0,
MaxResultsCount: 100
});

var Ranks = result.Data.Leaderboard;
}



than, when I call this function. It throw this Error.

==> TypeError: Cannot read property 'Leaderboard' of undefined

Leaderboard's Name -> Checked.

Leaderboard's contents -> Checked. is exist and i cloud get info through post via post man

is There any I'm missed it? or those are bugs??

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

brendan avatar image
brendan answered

The issue is that the return value for GetLeaderboard doesn't contain a "Data" element. It only contains "Leaderboard", so you could get to it like so:

handlers.CalcUserRank = function (args, context) {
                
  var result = server.GetLeaderboard({
  StatisticName: "TotalGainedPoint",
  StartPosition: 0,
  MaxResultsCount: 100
});

var Ranks = result["Leaderboard"];
}

 

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

chju1020 avatar image
chju1020 answered

Well, that's my wrong point!.

thanks for your reply!

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.