title: NuxtServerInit not working on Vuex module mode - Nuxt.js
body: <p>NuxtServerInit is not working on initial page render on nuxt js vuex module mode. But it works on Classic mode. Following code is the flow I used.</p>
  
  <p>My api call</p>
  
  <p>api/CategoryApi.js</p>
  
  <pre><code>import axios from 'axios';
  
  const HEADERS = {
      Accept: 'application/json'
  };
  
  export default {
      getCategory(payload) {
          return axios.get(`${process.env.apiUrl}/category`, {
              payload,
              headers: HEADERS
          });
      }
  }
  </code></pre>
  
  <p>store/modules/CategoryStore.js</p>
  
  <pre><code>import api from '~/api/CategoryApi'
  
  const state = () =&gt; ({
      categories: []
  });
  
  const getters = {
      allCategories: state =&gt; state.categories
  };
  
  const actions = {
      async nuxtServerInit({commit}) {
          const payload = {
              per_page: 6,
              page: 1
          };
          const response = await api.getCategory(payload);
          commit('setCategories', response.data.data);
      },
  };
  
  const mutations = {
      setCategories: (state, data) =&gt; {
          state.categories = data;
      }
  };
  
  export default {
      state,
      getters,
      actions,
      mutations
  }
  </code></pre>
  
  <p>pages/index.vue</p>
  
  <pre><code>&lt;template&gt;
      &lt;div&gt;
          &lt;v-flex xs6 sm4 md2 class="text-xs-center my-2 pa-2" v-for="category in allCategories" :key="category.id"&gt;
              {{ category.name }}
          &lt;/v-flex&gt;
      &lt;/div&gt;
  &lt;/template&gt;
  
  &lt;script&gt;
      import { mapGetters } from 'vuex';
  
      export default {
          layout: 'default',
          computed: {
              ...mapGetters({
                  allCategories: 'modules/CategoryStore/allCategories',
              })
          },
      }
  &lt;/script&gt;
  </code></pre>
  
  <p>Am I doing this wrong? :/ I want to know the right way to implement this.</p>
  
  <p><strong>Edit: How I did with Aldarund answer</strong> (This might help someone)</p>
  
  <p>Edited store/modules/CategoryStore.js</p>
  
  <pre><code>const actions = {
      async fetchCategories({commit}) {
          const payload = {
              per_page: 6,
              page: 1
          };
          const response = await api.getCategory(payload);
          commit('setCategories', response.data.data);
      },
  };
  </code></pre>
  
  <p>Added store/index.js</p>
  
  <pre><code>const actions = {
      async nuxtServerInit({dispatch}) {
          await dispatch('modules/CategoryStore/fetchCategories');
      },
  };
  
  export default {
      actions
  }
  </code></pre>