Following the tutorial I’m trying to make a JS service.
I’m running into the following problems, see JS code bellow:
-
When declaring getGameEvents as ‘function’ I’m getting the following error: Unexpected identifier
-
When declaring getGameEvents as an API compilation is good and running calling getGameEvents from the API Service works ok. but when running ‘calcGameScore’ that uses ‘getGameEvents’ the response is: “getGameEvents is not defined”
How can I call getGameEvents form calcGameScore?
Thank’s for your help
class Statistics {
/**
-
@param {String} gameId
-
@description load all events of a specific game
-
*/
async function getGameEvents(gameId){
const gamesStore = Backendless.Data.of(‘Games’)const query = Backendless.Data.QueryBuilder.create()
.setWhereClause(objectId = '${gameId}'
)
.setRelated(“events”)const games = await gamesStore.find(query);
return games[0].events
}
/**
-
@param {String} gameId
-
*/
async calcGameScore(gameId) {const events = getGameEvents(gameId)
/* do something with events */
return events
}
}
Backendless.ServerCode.addService(Statistics);