Open avimehenwal opened 4 years ago
This is not correct. Async data is used to amalgamate the component data after completion. Doing intermediate steps to update the store in this method are possible but not recommended. Use the mounted method to update the store if you want. Also, use mapActions to dispatch actions. Dispatching named events is tedious and error prone especially if the project gets bigger.
On Thu, Apr 2, 2020, 2:10 PM Avi Mehenwal notifications@github.com wrote:
client.js?06a0:84 Error: [vuex] do not mutate vuex store state outside mutation handlers. at assert (vuex.esm.js?2f62:90) at Vue.store._vm.$watch.deep (vuex.esm.js?2f62:793) at Watcher.run (vue.runtime.esm.js?2b0e:4568) at Watcher.update (vue.runtime.esm.js?2b0e:4542) at Dep.notify (vue.runtime.esm.js?2b0e:730) at Object.reactiveSetter [as country] (vue.runtime.esm.js?2b0e:1055) at getCountryCount (index.js?9101:65) at wrappedGetter (vuex.esm.js?2f62:781) at Vue.eval (vuex.esm.js?2f62:95) at Watcher.get (vue.runtime.esm.js?2b0e:4479)
async asyncData ({ store }) { // async asyncData ({ $axios, store }) { // let response = await $axios.$get('https://api.covid19api.com/summary') // this.updateStore(response.Countries) await store.dispatch('get') // return { country: response.Countries } // store.dispatch('fetch_COUNTRY') }
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/avimehenwal/covid-visualization/issues/1, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAJQ4PUJGR5SPYIXHOVH3N3RKPQW5ANCNFSM4LZY5UUQ .