Navigation

    Quasar Framework

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    1. Home
    2. CPHM
    C
    • Profile
    • Following 0
    • Followers 0
    • Topics 1
    • Posts 1
    • Best 0
    • Groups 0

    CPHM

    @CPHM

    0
    Reputation
    1
    Profile views
    1
    Posts
    0
    Followers
    0
    Following
    Joined Last Online

    CPHM Follow

    Latest posts made by CPHM

    • Accessing Vuex Store in Boot files

      I want to use vuex in a boot file to read user’s saved access token and info from LocalStorage and commit the data to store and use it in other boot files (for example axios boot file) and vue components. I tried to export Vuex instance from the src/store/index but I get the following error:

      Uncaught ReferenceError: Cannot access 'store' before initialization
      

      Here is my src/store/index:

      import Vue from "vue";
      import Vuex from "vuex";
      
      import auth from "./auth";
      
      let store = null;
      
      Vue.use(Vuex);
      
      export default function (/* { ssrContext } */) {
        const Store = new Vuex.Store({
          modules: {
            auth,
          },
        });
      
        store = Store;
      
        return Store;
      }
      
      export { store };
      

      and I just imported the instance in boot files:

      import { store } from "src/store";
      

      By the way I tried putting a console.log() in the createStore function in store/index and it doesn’t show up.

      posted in CLI
      C
      CPHM