Hi,
I tried creating an Authoritative Leaderboard according to the instructions but I can’t? It always gives an error:
"rpc error: code = Internal desc = TypeError: Cannot read property 'DESCENDING' of undefined at writeLeaderboard (index.js:34:29(12))"
I code in index.js but not in typescript, so I can’t find nkruntime according to the instructions.
Can someone check for me?
Here is the instruction code:
let id = '4ec4f126-3f9d-11e7-84ef-b7c182b36521';
let authoritative = true;
let sort = nkruntime.SortOrder.DESCENDING;
let operator = nkruntime.Operator.BEST;
let reset = '0 0 * * 1';
let metadata = {
weatherConditions: 'rain',
};
try {
nk.leaderboardCreate(id, authoritative, sort, operator, reset, metadata);
} catch(error) {
// Handle error
}
Below is the code in my index.js. nkruntime or nk both report errors.
let writeLeaderboard = function (ctx, logger, nk, payload)
{
logger.info('leaderboardCreate called');
let id = '4ec4f126-3f9d-11e7-84ef-b7c182b36521';
let authoritative = true;
let sort = nk.SortOrder.DESCENDING;
let operator = nk.Operator.BEST;
let reset = '0 0 * * 1';
let metadata = {
weatherConditions: 'rain',
};
let result;
try {
result = nk.leaderboardCreate(id, authoritative, sort, operator, reset, metadata);
} catch(error) {
return JSON.stringify({ code: 0, status: "BadRequest", data: error });
}
return JSON.stringify({ code: 1, status: "OK", data: result });
};