This commit is contained in:
j-weissen 2023-01-20 13:57:26 +01:00
parent fd235b56c6
commit 1ed1189bec
2 changed files with 20 additions and 18 deletions

View file

@ -12,10 +12,10 @@
</div>
<div class="row">
<div class="col-4">
<Leaderboard :title="'Highscore'" :leaderboard="this.highscoreLeaderboard"></Leaderboard>
<Leaderboard type="highscore"></Leaderboard>
</div>
<div class="offset-4 col-4">
<Leaderboard :title="'Total Playtime'" :leaderboard="this.totalPlaytimeLeaderboard"></Leaderboard>
<Leaderboard type="totalplaytime"></Leaderboard>
</div>
</div>
</div>
@ -55,15 +55,9 @@ export default defineComponent({
async fetchUserScores() {
return await this.fetchFromApi(`/user/${this.userId}/scores`, "GET");
},
async fetchLeaderboard(type: "highscore" | "totalplaytime") {
return await this.fetchFromApi(`/leaderboard/${type}`, "GET");
},
},
async created() {
this.userScores = await this.fetchUserScores();
this.highscoreLeaderboard = await this.fetchLeaderboard("highscore")
this.totalPlaytimeLeaderboard = await this.fetchLeaderboard("totalplaytime")
console.log(this)
}
});
</script>