[Vuejs]-Vuex: How to grab latest user data after user profile updated?

0👍

after you update the detail of the user you can fire an event which may will fetch the data from the server behind the scene.

methods:{
loadData(){
         await this.$store.dispatch('getSSOUser') ;
         await this.$store.dispatch('fetchUserProfiles');
         await this.setUser()
         this.isBusy = false
          },
updateInfo() {
                this.form.put('api/profile').then((response) => {
                let userData = response.data.userdata;
                Fire.$emit('ProfileEvent');
            }
           },
  },
created(){
        this.loadData();
        Fire.$on('ProfileEvent', () => {
        this.loadData();
        });
       }

may be firing an event after the there is any changes saved in the profile page and executing the function that is called when the component is created after the fired event may resolve your problem. Hope you will get the idea from above code example.

Leave a comment