How to call a method in the component vue after getting data from vuex?

Hello!
This problem, in the root component of App is called an asynchronous method request data to the server. Data is stored in vuex storage. And need to execute a method when the data are obtained. The data receive component through mapGetters of vuex.
And need to know if the data is to call.
I did this:
watch: {
 currentUser: function(user){ //currentUser - computed property derived from vuex
 console.log('get previews for user:', user);
 this.getPreviewsForUser(user.token) //must be called if currentUser is
},
 },

But it's not working. Just reload the page to re-load currentUser
June 8th 19 at 16:40
2 answers
June 8th 19 at 16:42
User compare with undefined, null, or what have you.
he never called - that's the trick - Ashtyn.Rau65 commented on June 8th 19 at 16:45
, , in fact, not so. It works 1 time. The data is loaded in one component - it worked. Pass in another component (tab) is watch sees that data, but they are not changed, and the second method does not work anymore - Ashtyn.Rau65 commented on June 8th 19 at 16:48
June 8th 19 at 16:44
Later, of course, but I think you can:
in Vuex action to request data and to execute the following method
actions = {
 async getUser({ commit }) {
 const { data } = await axios.get('http://...');
 if (data.user) {
 commit(SET_USER, data.user);
 dispatch('getPreviewsForUser', data.user.token)
 } else {
...
}

 return data;
},
 getPreviewsForUser({commit}, token) { //or using state token to;
...
}
};

Find more questions by tags Vue.js