0👍
main.js
You will need to wait for the dispatch to resolve.
import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
const app = createApp(App)
store.dispatch('users/getUser')
.then(() => {
app.use(store).use(router).mount('#app');
});
Or wrap the dispatch in an async
function. And await
the dispatch itself.
Source:stackexchange.com