0👍
thanks to @YongQuan I have this solution.
methods: {
...mapActions(['destroyToken']),
destroySessionIfTokenIsExpired() {
const expiresOn = localStorage.getItem('expires_on')
const expiresDate = moment(expiresOn).format('YYYYMMDDHHMMSS')
if(expiresOn == null) return;
const current = new Date(moment())
const currentDate = moment(current).format('YYYYMMDDHHMMSS')
if(currentDate >= expiresDate) {
this.$store.dispatch('destroyToken')
this.$router.push('/login')
} else return;
}
},
watch: {
'$route': function(to, from) {
this.destroySessionIfTokenIsExpired()
}
},
Instead of using a getter
I just set the `localStorage.getItem(‘expires_on’) to a variable inside the method. Thanks @YongQuan
- [Vuejs]-Nodemailer Connection timeout at SMTPConnection._formatError
- [Vuejs]-Setting Custom Editor shows kendoDropDownList is not a function
Source:stackexchange.com