I'm trying to dispatch action in fetch hook in NuxtJS
async fetch() {
return await this.$nuxt.context.store.dispatch('settings/getSettings')
}
then
<el-table v-if="!$fetchState.pending" :data="settings.colors">
...
</el-table>
them
computed: {
...mapState({
loading: 'settings/loading',
settings:'settings/settings'
}),
}
In the end I get an error colours is undefined, But the code below works, without Vuex
async fetch() {
return await this.$axios.$get(EP_GET_DATA_SETTINGS).then((data)=>{
this.settings = data
})
}
Please advise how to solve this problem