diff --git a/src/components/PersonalHighscorePage.vue b/src/components/PersonalHighscorePage.vue
index 1d7b397..40fd738 100644
--- a/src/components/PersonalHighscorePage.vue
+++ b/src/components/PersonalHighscorePage.vue
@@ -40,6 +40,10 @@
+
+
+ {{ error }}
+
@@ -58,7 +62,8 @@ export default {
},
data() {
return {
- winner: undefined
+ winner: undefined,
+ error: undefined
}
},
computed: {
@@ -66,6 +71,12 @@ export default {
return this.winner.highscore.length
}
},
+ created() {
+ const nameFromURL = this.$route.params.name;
+ getWinnerByName(nameFromURL)
+ .then(winner => this.setWinner(winner))
+ .catch(err => this.error = `Ingen med navn: "${nameFromURL}" funnet.`)
+ },
methods: {
setWinner(winner) {
this.winner = winner
@@ -94,11 +105,6 @@ export default {
},
humanReadableDate: humanReadableDate,
daysAgo: daysAgo
- },
- created() {
- const nameFromURL = this.$route.params.name;
- if (this.winnerObject === undefined && nameFromURL !== null)
- getWinnerByName(nameFromURL).then(winner => this.setWinner(winner))
}
}