title: store is not defined vue.js
body: <p>I have created login page. router intercepting the request and validates the user is authenticated or not . store is maintaining the user is logged in or not.</p>
  
  <p>while debugging i am getting in auth.js</p>
  
  <blockquote>
    <p>"store is not defined" </p>
  </blockquote>
  
  <p>I also tried relative path instead of @  in imports. </p>
  
  <p>router code snippet   </p>
  
  <pre><code>      import auth from '@/services/auth';
         ...
          router.beforeEach((to, from, next) =&gt; {
        if (to.matched.some(record =&gt; record.meta.requiresAuth)) {
          if (!auth.loggedIn()) {
            next({
              path: '/login',
            });
          } else {
            next();
          }
        } else {
          next(); 
        }
      });
  </code></pre>
  
  <p>auth.js is like service which will interact with store and maintain state .</p>
  
  <pre><code>import Vue from 'vue';
  import axios from 'axios';
  import VueAxios from 'vue-axios';
  import store from '@/store/UserStore';
  
  Vue.use(VueAxios, axios);
  
  export default {
    login(credentials) {
      return new Promise((resolve, reject) =&gt; {
        Vue.axios.post('/api/authenticate', credentials).then((response) =&gt; {
          localStorage.setItem('token', response.body.token);
          store.commit('LOGIN_USER');
          resolve();
        }).catch((error) =&gt; {
          store.commit('LOGOUT_USER');
          reject(error);
        });
      });
    },
    isUserLoggedIn() {
      return store.isUserLoggedIn();
    },
  };
  </code></pre>
  
  <p>here is my store to </p>
  
  <pre><code>import Vue from 'vue';
  import Vuex from 'vuex';
  
  Vue.use(Vuex);
  
  export default new Vuex.Store({
    strict: process.env.NODE_ENV !== 'production',
    state: {
      isLogged: !localStorage.getItem('token'),
      user: {},
    },
    actions: {
  
    },
    mutations: {
      /*  eslint-disable no-param-reassign */
      LOGIN_USER(state) {
        state.isLogged = true;
      },
      /* eslint-disable no-param-reassign */
      LOGOUT_USER(state) {
        state.isLogged = false;
      },
    },
    getters: {
      isUserLoggedIn: state =&gt; state.isLogged,
    },
    modules: {
  
    },
  });
  </code></pre>