Answer the question
In order to leave comments, you need to log in
How to properly separate component, storage and API requests?
Good afternoon. My application uses a Vuex store and a separate set of methods to query the view API
export default {
get() {return axios.get(....)},
}
Answer the question
In order to leave comments, you need to log in
2. Reverse opinion Alex :
On the contrary, I prefer to store all the data in the store. Components only have local variables.
All requests to the API are located in actions and, accordingly, the data is immediately placed in the store.
Accessing the store only through getters. The necessary actions and getters are mapped into the component.
3. It is convenient to intercept errors in Axios interceptors. We configure the option validateStatus
as needed and catch everything in one place.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question