No More Posting New Topics!

If you have a question or an issue, please start a thread in our Github Discussions Forum.
This forum is closed for new threads/ topics.

Navigation

    Quasar Framework

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    Accessing to store in the router

    Help
    2
    2
    256
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • J
      jerlive last edited by jerlive

      Hello Quasar lovers,

      I got an issue with my router (or store ?). I can’t access to data in the store before entering a route.
      Just in case, i made a topic in stackoverflow too: https://stackoverflow.com/questions/65144080/accessing-to-store-in-the-router/65145838#65145838
      But I prefer to create a topic here because I am pretty sure you can help me.

      Last week I worked on the store, but It was really hard for me (I’m used to work on Vuejs 2.0 with Vuex) but with Quasar it was so hard (for my collegue and me) to find how to work with this Vuex (from Quasar) syntax. So I finally reinstalled Vuex (with NPM, not with Quasar CLI) and my store is working great with my components.
      I can just use this syntaxe properly in the components:

      ...mapGetters(['userInfos'])
      

      But now, I got this issue that i can’t access to the data in the store from the router. and i’m starting guessing that IS BECAUSE I reinstalled vuex.
      Or maybe because I don’t see any module name prefix in the consolelog, even NOT in the vue developer tool, that’s why I can’t consolelog like that:

      store.getters['user/userInfos']
      

      Probably because the name of the module isn’t declared somewhere?
      Maybe can you guys confirm?

      here the details of the problem:

      When I console.log(store.myStore.getters) I can see everything:
      alt text

      But when I console.log(store.myStore.getters.userInfos), I don’t see anything:
      alt text

      There are the files of the router (2 files) and store (2 files):

      Index.ts (store) : https://codeshare.io/G8m6Qj
      module: user.js : https://codeshare.io/5eAekL

      index.ts (routeur) : https://codeshare.io/29lwJB
      routes.ts : https://codeshare.io/aJEYmy

      Thank you!

      dobbel 1 Reply Last reply Reply Quote 0
      • dobbel
        dobbel @jerlive last edited by dobbel

        @jerlive said in Accessing to store in the router:

        So I finally reinstalled Vuex (with NPM, not with Quasar CLI)

        Don’t think this is a good idea. Please remove the npn installed version of vuex. For the rest of this thread I assume you have done this.

        I can’t access to data in the store before entering a route.

        your store/index.ts exports a store module instead of an actual store. I suspect the src/store/index.js|ts file must export a store for Quasar to work properly with vuex.

        1 Reply Last reply Reply Quote 0
        • First post
          Last post