I have converted nuxt2 store/index.js to nuxt3 store as below
store/index.js
const state = () => ({
counter: 0
})
const getters = {
getCounter(state) {
return state.counter
}
}
const mutations = {
increment(state) {
state.counter++
}
}
const actions = {
async fetchCounter({ state }) {
// make request
const res = { data: 10 };
state.counter = res.data;
return res.data;
}
}
const store = new useStore({
state,
getters,
mutations,
actions,
})
export default store
plugin/vuex.js
import store from '~/store'
export default defineNuxtPlugin(nuxtApp => {
nuxtApp.vueApp.use(store)
})
when i call $store.dispatch('fetchCounter', data) then it inform error can not find action.
pls help me take a look at store/index.js if any error missing config
I have converted nuxt2 store/index.js to nuxt3 store as below store/index.js
plugin/vuex.js
when i call $store.dispatch('fetchCounter', data) then it inform error can not find action. pls help me take a look at store/index.js if any error missing config