Put geo location fetch in try/catch

This commit is contained in:
Moritz Kröger 2019-05-09 17:20:59 +01:00
parent cf2bddf130
commit 782c64a683
2 changed files with 9 additions and 5 deletions

View file

@ -121,9 +121,15 @@
},
async created () {
const ipResponse = await fetch(IPDATA_URL)
const ipData = ipResponse.json()
this.userCountry = ipData.country_code
try {
const ipResponse = await fetch(IPDATA_URL)
const ipData = ipResponse.json()
if (ipData.country_code) {
this.userCountry = ipData.country_code
}
} catch (error) {
console.warn('Unable to fetch geo location:', error)
}
},
methods: {

View file

@ -55,8 +55,6 @@ export function getTranslatedAliases (data, section) {
)]
}
console.log('getTranslatedAliases inside', getTranslatedAliases)
export function getTranslatedUrl (section, prefixUrl, omitLocale = false) {
const messages = i18n.messages[getCurrentLocale()][section]
const url = messages.url