🐛 Fixes import issue with async methods

This commit is contained in:
Moritz Kröger 2019-05-09 15:52:03 +01:00
parent 50c4f93a2c
commit cf2bddf130
4 changed files with 9 additions and 11 deletions

View File

@ -30,10 +30,11 @@
<script>
import '@/assets/icons/european-stars'
import { IPDATA_URL } from '@/config/api'
import { GA_COOKIE_NAME } from '@/config/analytics'
import { SUPPORTED_LOCALES } from '@/config'
import { setCookie, getCookie } from '@/helper/cookies'
import { getCountryByIP, getUserLanguage, getTranslatedUrl } from '@/i18n/helper'
import { getUserLanguage, getTranslatedUrl } from '@/i18n/helper'
export default {
name: 'App',
@ -120,7 +121,8 @@
},
async created () {
const ipData = await getCountryByIP()
const ipResponse = await fetch(IPDATA_URL)
const ipData = ipResponse.json()
this.userCountry = ipData.country_code
},

View File

@ -2,7 +2,7 @@ import { DEFAULT_LOCALE } from '@/config'
import i18n from '@/i18n'
import localI18n from './i18n'
import { storageAvailable } from '@/helper/storage'
import { getTranslatedAliases, getTranslatedTitles } from '@/i18n/helper'
import { getTranslatedTitles, getTranslatedAliases } from '@/i18n/helper'
function hasAnswers (to, from, next) {
if (storageAvailable('sessionStorage') && !sessionStorage.getItem('euromat-answers')) {

View File

@ -1,12 +1,6 @@
import { DEFAULT_LOCALE, SUPPORTED_LOCALES } from '@/config'
import { IPDATA_URL } from '@/config/api'
import i18n from './index'
export const getCountryByIP = async () => {
const response = await fetch(IPDATA_URL)
return response.json()
}
export const isLangSupported = lang =>
SUPPORTED_LOCALES.some(([locale]) => locale === lang)
@ -61,6 +55,8 @@ 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

View File

@ -1,7 +1,7 @@
import Vue from 'vue'
import Router from 'vue-router'
import * as i18n from '@/i18n/helper'
import { getUserSupportedLanguage } from '@/i18n/helper'
import BaseLocaleRouter from '@/components/base-locale-router'
import { getPageTitle, beforeEnter } from '@/router/helper'
@ -41,7 +41,7 @@ const router = new Router({
{
path: '*',
redirect (to) {
return i18n.getUserSupportedLanguage()
return getUserSupportedLanguage()
}
}
]