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

    access the store

    Framework
    2
    3
    223
    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.
    • E
      eloy.silva last edited by

      Hi,
      I am trying to access the store.state.xxx but I cannot, I am new with this technology and I have been confused

      import Vue from 'vue'
      import VueRouter from 'vue-router'
      
      import routes from './routes'
      import store from 'src/store/'
      
      
      Vue.use(VueRouter)
      
      /*
       * If not building with SSR mode, you can
       * directly export the Router instantiation;
       *
       * The function below can be async too; either use
       * async/await or return a Promise which resolves
       * with the Router instance.
       */
      
      export default function ( {router, store, Vue}/* { store, ssrContext } */) {
        const Router = new VueRouter({
          scrollBehavior: () => ({ x: 0, y: 0 }),
          routes,
      
          // Leave these as they are and change in quasar.conf.js instead!
          // quasar.conf.js -> build -> vueRouterMode
          // quasar.conf.js -> build -> publicPath
          mode: process.env.VUE_ROUTER_MODE,
          base: process.env.VUE_ROUTER_BASE
        })
      
      
        Router.beforeEach((to, from, next) => {
          if (to.matched.some(record => record.meta.requiresAuth)) {
            // this route requires auth, check if logged in
            // if not, redirect to login page.
      
            if (!store.state.loggedIn) {
              next({
                name: 'Security/Login',
      
              })
            } else {
              next()
            }
          } else {
            next() // make sure to always call next()!
          }
        })
      
        return Router
      }
      
      
      
      

      this my store:

      import { firebaseAuth, firebaseDb } from "boot/firebase";
      import { axiosInstance } from "boot/axios";
      
      const state = {
        TOKEN: null,
        loggedIn: false,
        userDetails: {},
        loading_login: false,
        currentPage: {
          title: "",
          IsActive: false
        },
      
        CONFIGSYS: {
          COMPANY_ID: 0
        }
      };
      
      

      😰

      Thanks in advance

      1 Reply Last reply Reply Quote 0
      • J
        jadedRepublic last edited by jadedRepublic

        import { firebaseAuth, firebaseDb } from "boot/firebase";
        import { axiosInstance } from "boot/axios";
        
        const state = {
          TOKEN: null,
          loggedIn: false,
          userDetails: {},
          loading_login: false,
          currentPage: {
            title: "",
            IsActive: false
          },
        
          CONFIGSYS: {
            COMPANY_ID: 0
          }
        };
        
        export default state <-- Add this at the bottom
        
        E 1 Reply Last reply Reply Quote 0
        • E
          eloy.silva @jadedRepublic last edited by

          @jadedRepublic
          thanks
          😁

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