Can I call the value of Axios asynchronously in the getter method in vuex?

first let"s talk about my understanding of vuex. I think we should put the data used by multiple pages or components in vuex to avoid loading interface data on every page, especially some dictionary table configuration, etc., which rarely changes. Am I right?
if there are multiple pages that need to use the same set of data, which comes from the backend API and needs to be obtained by axios, then the vuex requires explicitly calling commit to execute the setting method. Should I call an asynchronous Action with a value in each page? In this case, in fact, every page to call the interface, it is equivalent to not using Vuex ah?
I hope to set up state, in vuex to set action to call axios value and call mutaction to assign it to state,. On multiple pages that use data, use the getter method to take the value directly. In this getter method, first determine whether the data is empty, if it is empty, call actions value assignment, and then return state to the called page, that is, similar to cache usage. If there is any, it will be returned directly. If there is none, get it first and then return it. How can this be achieved? Getter methods all seem to return values directly. If asynchrony is still to be handled in it, can it be implemented?

Apr.15,2021

it is best not to handle asynchronous requests in Getters. Please put asynchronous requests in actions. Getters, which you can understand as the computed calculation property of vue, will be cached.
you can consider using the watch method

.
Menu