title: NuxtJS: How to access Vuex state on Server side
body: <p>I am using NuxtJS <a href="https://nuxtjs.org/api/pages-fetch/#nuxt-gt-2-12" rel="nofollow noreferrer">fetch()</a> hook to get asynchronous data from a REST service. Following is the request</p>
  <pre><code>async fetch() {
    let response = await this.$axios.$get(`http://localhost:8080/app-server/v1/post/id/${this.$route.params.id}`);
  }
  </code></pre>
  <p>I also need to send an optional query parameter <code>uid</code>, which is the user id in case a user is logged in. User Id is stored in Vuex state and can be accessed on client side like below</p>
  <blockquote>
  <p>this.$store.state.user.userDetails.id</p>
  </blockquote>
  <p>But when the page is reloaded and <em>fetch()</em> is executed on server side this returns <em>null</em>. I am looking for a way to access this state on server side as well. I tried using Nuxt context <code>this.$nuxt.context</code> like below but it too returns <em>null</em> when runs on server side.</p>
  <blockquote>
  <p>this.$nuxt.context.store.state.user.userDetails.id</p>
  </blockquote>
  <p>Any suggestions how can I access Vuex state on server side. Thanks</p>