I’m wondering what is the best practice for fetching remote data and the persisting it in vuex.
Like I see it there’s two possible ways to do this;
A. Use a getter to check if user has been fetched already, if not, dispatch an action to fetch it and commit the data to the local state.
B. Use a action to first check if the user exists by a getter, if not, fetch it and commit the data to the local state.
Which is the best way to go about this?
It would be nice to only have one method in the component for retrieving the user.
Eg, I don’t wanna have to first use the getter, validate its response, and then dispatch an action if there’s no data in the local store.