title: How to access a Vuex getter from Vue router
body: <p>I have a <code>index.js</code> file which contains my routes and I'm trying to create a <code>beforeEnter</code> guard on the admin panel route and only let authenticated admins in. The problem is that when I <code>console.log(store.getters.isLoggedIn)</code>, I get this:</p>
  <pre><code>ƒ isLoggedIn(state) {
      return state.user.token ? true : false
  }
  </code></pre>
  <p>instead of <code>true</code> or <code>false</code> and I'm not sure why is this happening. My getter looks like this:</p>
  <pre><code>getters: {
      isLoggedIn: state =&gt; {
          return state.user.token ? true : false
      }
  }
  </code></pre>
  <p>and my routes are here:</p>
  <pre><code>import Vue from 'vue'
  import VueRouter from 'vue-router'
  import Home from '../views/Home.vue'
  import AdminPanel from '../views/AdminPanel.vue'
  import store from &quot;../store/authentication.js&quot;;
  
  Vue.use(VueRouter)
  
  const routes = [
      {
          path: '/',
          name: 'home',
          component: Home
      },
      {
          path: &quot;/admin&quot;,
          component: AdminPanel,
          beforeEnter: (to, from, next) =&gt; {
              console.log(store.getters.isLoggedIn)
          }
      }
  ]
  
  const router = new VueRouter({
      mode: 'history',
      base: process.env.BASE_URL,
      routes
  })
  
  export default router
  </code></pre>
  <p>store.js</p>
  <pre><code>import Vue from 'vue'
  import Vuex from 'vuex'
  import authentication from './authentication'
  import cart from './cart'
  
  Vue.use(Vuex)
  
  const store = new Vuex.Store({
      modules: {
          authentication,
          cart
      }
  })
  
  export default store
  </code></pre>
  <p>authentication.js</p>
  <pre><code>const authentication = {
      state: {
          user: null
      },
      getters: {
          isLoggedIn: state =&gt; {
              return state.user.token ? true : false
          }
      }
  }
  
  export default authentication
  </code></pre>