Static GitHub Issues

[1384] What is the best way to access this.$router.push() / router.push() inside the Vuex?

prev: [internals] improve options module
next: Absolute paths of working directory in build output scripts

This seems a silly question but I'm really struggling right now to accomplish a simple router.go('/') inside store/index.js. Basically I want to change the page after I complete the authentication. I'm using this example as base.

I know const router = require('~router'); isn't working anymore since rc-3 removed the alias to ~router.

I tried access this.$router but isn't available either. I also tried import router from 'vue-router'; with no luck :(


Here a partial of my store/index.js:

export const actions = {
  // Login
  async login({ commit }, { email, password }) {
    await axios.post('/api/account/login', {
      email,
      password,
    })
      .then((response) => {
        console.log('response:', response);

        if (response.status === 200) {
          console.log('>> Login successfull');
          commit('SET_USER', response.data);
          sessionStorage.setItem('user', JSON.stringify(response.data));

          //I can't make work!
          Router.push('/about');
        } else if (response.status === 204) {
          console.log('>> Username password do not match');
        } else {
          console.log('>> Username does not exists');
        }
      })
      .catch((error) => {
        commit('SET_USER', null);

        console.log('OPS!');
        console.log(error);
      });
  },
};

I appreciate any help... Thanks in advance!

<!--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/c1227">#c1227</a>)</em></sub></div>