1👍
My solution was to create an action in the store.js file that calls Auth.currentsession, and in the App.vue file dispatch the refreshSession event every 9 minutes.
store.js
import { createStore } from 'vuex'
import { Auth } from 'aws-amplify'
export default createStore({
state: {
session: null
},
getters: {
},
mutations: {
setSession(state, value){
state.session = value
}
},
actions: {
async refreshSession({ commit }){
const session = await Auth.currentSession()
commit('setSession', session)
}
},
modules: {
}
})
App.vue
created(){
this.sessionInterval = setInterval(() => {
this.$store.dispatch('refreshSession');
}, 540000);
},
- [Vuejs]-Load Nuxt project to exist express app
- [Vuejs]-The promise code never work as I expect. What is the mistake in my code?
Source:stackexchange.com