[Vuejs]-How I can wait an async function in my App.vue before mount next component?

0👍

You can’t, the async/await is a "Fake sync" apearence but in realy is a Async process, you can’t wait to finish, all vue enviroment will continue.

But you can use a correct use of Vuex to detect a change of store using getters, when you change a Data using a commit a "call change event" is fire across all getters functions and the change is reactive.

Please read the Vuex documentation and if you want a solution, please write the final propouse of lang variable.

EDIT:

I don’t know what are you using for i18n, but i think that vue-i18n can change on hot with location hot changes:

https://kazupon.github.io/vue-i18n/

0👍

you can use .then and finally

  await this.device.getLanguageCode()
   .then(({ data }) => {
     lang.value != "en" && lang.value != "fr"
        ? this.$store.commit("setLang", "en")
        : this.$store.commit("setLang", lang.value);
    })
    .catch(function(error) {
      console.log(error);
    }).finally(()=>{ 

    });

Leave a comment