I am currently utilizing Vuex to manage the state of my application.
In order to retrieve data from a rest API via an Ajax Get request and display a list of objects, I am dispatching an action to fetch this data from the server. However, I am unsure how to properly handle it within the component.
Currently, my code looks like this:
//component.js
created(){
this.$store.dispatch("fetch").then(() => {
this.objs = this.$store.state.objs;
})
}
Although this works, I believe there might be a more efficient way to manage store data instead of directly assigning it to a local property.
Is there a better approach to handling this using mapState or any other method?
Thank you!