title: accessing vuex store's state in .js file
body: <p>auth.js</p>
  
  <pre><code>export default {
  state: {
      token: localStorage.getItem('token') || null,
  },
  getters: {
      authToken: state =&gt; state.token,
  },
  </code></pre>
  
  <p>store.js</p>
  
  <pre><code>import Vue from 'vue'
  import Vuex from 'vuex'
  import auth from './modules/auth'
  Vue.use(Vuex)
  
  export const store = new Vuex.Store({
    modules: {
      auth,
     },
  })
  </code></pre>
  
  <p>Now I wanted to get <code>token</code> from any <code>.js</code> file. I tried as following but I am getting <code>cannot read property state of undefined</code>. If I use <code>getter</code> then error is <code>cannot read property getters of undefined</code></p>
  
  <p>config.js</p>
  
  <pre><code>import  {store}  from '../../store/store'
  
  // const token = store.getters.authToken;
   const token = store.state.auth.token;
  </code></pre>
  
  <p>File structure: </p>
  
  <pre><code>src/
     services/
             config/
                config.js
     store/
        modules/
              auth.js
        store.js
  </code></pre>
  
  <p>Edit: </p>
  
  <pre><code> warning  in ./src/services/config/config.js
  
  "export 'default' (imported as 'store') was not found in 
  '../../store/store'
  </code></pre>