[Vuejs]-Vue component can't read async state change

0👍

Vuex actions return promises, so you can add a .then() to the actions call to know when it is complete:

mounted() {
  this.$store.dispatch('loadUser').then(() => {
    // Update component state here
    console.log('User loaded: ', this.$store.state.user);
    this.delivery_address = this.$store.state.user.delivery_address;
  }
}

Leave a comment