Do funktionierts scho

This commit is contained in:
s-prechtl 2023-01-21 09:23:40 +01:00
parent da018a5c73
commit 3b034edc52
3 changed files with 9 additions and 2 deletions

View file

@ -73,6 +73,8 @@ export default defineComponent({
this.userId = user.id ?? -1; this.userId = user.id ?? -1;
await this.updateUserScores(); await this.updateUserScores();
} }
let reloadEvent = new Event('reloadLeaderboard');
window.dispatchEvent(reloadEvent);
} }
}, },
}); });

View file

@ -45,10 +45,14 @@ export default {
let body = { let body = {
score: score, score: score,
playtime: playTime, playtime: playTime,
date: new Date().toISOString(), date: new Date().toISOString().substring(0, 10),
userId: this.userId, userId: this.userId,
} }
await fetch(Rest.URL + '/game/add', {method: 'POST', body: JSON.stringify(body)}); let header = {
Accept: "application/json",
"Content-Type": "application/json",
};
await fetch(Rest.URL + '/game/add', {method: 'POST', body: JSON.stringify(body), headers: header});
this.$emit('gameFinished'); this.$emit('gameFinished');
} }
}, },

View file

@ -39,6 +39,7 @@ export default {
}, },
created() { created() {
this.updatePage(); this.updatePage();
window.addEventListener('reloadLeaderboard', () => {this.updatePage()}, false)
}, },
methods: { methods: {
async fetchPage() { async fetchPage() {