Vuex: Access State From Another Module
<p>I want to access <code>state.session</code> in <code>instance.js</code> from <code>records_view.js</code>. How is this accomplished?</p>

<p><strong>store/modules/instance.js</strong></p>

<pre><code>const state = {
  // This is what I want to access in records_view.js
  session: {}
};

const getters = {
  sessionGetter: state =&gt; state.session
};
</code></pre>

<p><strong>store/modules/records_view.js</strong></p>

<pre><code>const actions = {
  getSettingsAction (context, props) {
    // This is how I'm trying to access session, which doesn't work
    let session = context.state.instance.session;

    Api(
      context,
      {
        noun: props.noun,
        verb: 'GetRecordsViewSettings',
        orgUnitKey: _.has(session, 'orgunit.key') ? session.orgunit.key : '',
        data: {}
      },
      props.callback
    );
  }
};
</code></pre>

<p>This is for a little bit of added context.</p>

<p><strong>store/index.js</strong></p>

<pre><code>import Vue from 'vue';
import Vuex from 'vuex';
import * as actions from './actions';
import * as getters from './getters';
import * as types from './mutation-types';

import instance from './modules/instance';
import recordsView from './modules/records_view';

Vue.use(Vuex);

export default new Vuex.Store({
  state,
  actions,
  getters,
  mutations,
  modules: {
    instance,
    recordsView
  }
});
</code></pre>