Answer the question
In order to leave comments, you need to log in
Why doesn't nuxtServerInit work in vuex modules?
nuxtServerInit doesn't fire when used in vuex modules.
async nuxtServerInit({commit}){
await this.$axios
.get(apiURL + '/section')
.then((result) => {
commit('SET_SECTION_LIST', result.data)
})
.catch((error) => {
commit('SET_ERRORS', error)
})
}
Answer the question
In order to leave comments, you need to log in
If you are using the Modules mode of the Vuex store, only the primary module (in store/index.js) will receive this action. You'll need to chain your module actions from there.
nuxtServerInit is only called from the main module. You can call dispatch to notify another module.
async nuxtServerInit({ dispatch }) { await dispatch('core/load') }
Documentation
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question