From 782c64a68333cb8fc89780087230eb2548e82056 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20Kr=C3=B6ger?= Date: Thu, 9 May 2019 17:20:59 +0100 Subject: [PATCH] :zap: Put geo location fetch in try/catch --- src/app/app.vue | 12 +++++++++--- src/i18n/helper.js | 2 -- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/app/app.vue b/src/app/app.vue index 7595d61..a659395 100644 --- a/src/app/app.vue +++ b/src/app/app.vue @@ -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: { diff --git a/src/i18n/helper.js b/src/i18n/helper.js index 0ef5c8b..c6cde18 100644 --- a/src/i18n/helper.js +++ b/src/i18n/helper.js @@ -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