Home

Issue: 1543

New to Nuxt question

[issue link]

I noticed that folder store is automagically loaded, my question is, how do I get the store object to use directly? I’m aware that methods like fetch, asyncData, and nuxtServerInit have access to commit, dispatch and the like, but how do I do this:

store.dispatch('action',data)

from within a component tags but not necessary the exported methods?

for example, suppose I want to invoke an action from created, there is no { store } as there would be for asyncData.

export default {
  asyncData({store}) {
    // store is available here
  },
  created({store}) {
   // store is not available here
  }

Does it make sense to import store?

import { store } from '../store/index'

Seems like it should be unnecessary since this file is already imported (?)

This question is available on Nuxt.js community (#c1374)