Static GitHub Issues

[2005] Accessing the store from an external file

prev: How to get data from local json file using actions and axios.get()?
next: [nuxt] Error while initializing app DOMException: Failed to execute 'appendChild' on 'Node': This node type does not support this method.
// ~/store/index.js
import Vuex from 'vuex';

export default () => new Vuex.Store({
    actions: {
        someAction() {
            //
        }
    }
});
// external js file
import store from '~/store';

export default class AuthService {
    static login() {
        store.dispatch('someAction');
    }
}

I get an error when app builds:

TypeError: __WEBPACK_IMPORTED_MODULE_2__store__.default.dispatch is not a function
    at AuthService.js:10
    at <anonymous>

How can I dispatch an action of vuex in an external js file (not vue component)?

<!--cmty--><!--cmty_prevent_hook--><div align="right"><sub><em>This question is available on <a href="https://nuxtjs.cmty.io">Nuxt.js</a> community (<a href="https://nuxtjs.cmty.io/nuxt/nuxt.js/issues/c1780">#c1780</a>)</em></sub></div>