30 lines
606 B
JavaScript
30 lines
606 B
JavaScript
class LeaderboardService {
|
|
constructor(config) {
|
|
this.baseUrl = config.API_BASE_URL;
|
|
this.urlTail = "leaderboard";
|
|
}
|
|
|
|
async getLeaderboard(offset, limit) {
|
|
const response = await fetch(
|
|
`${this.baseUrl}${this.urlTail}?offset=${offset}&limit=${limit}`,
|
|
{
|
|
method: "GET",
|
|
},
|
|
);
|
|
let body = null;
|
|
try {
|
|
body = await response.json();
|
|
} catch {
|
|
console.error("Error in getLeaderboard");
|
|
}
|
|
|
|
return {
|
|
status: response.status,
|
|
ok: response.ok,
|
|
body: body,
|
|
};
|
|
}
|
|
}
|
|
|
|
window.LeaderboardService = LeaderboardService;
|