I have a function that allows me to delete an account by calling the deleteAccount function. After successfully deleting the account, I would like the user to be automatically logged out from the vuex store. Although I currently use setTimeout as a workaround for this, I believe there may be a more efficient solution available. Can someone please recommend a better approach for achieving this logout functionality?
deleteAccount component
logout: function () {
this.$store.commit(SET_LOGOUT);
this.$store.commit(RESET_BASIC_MODAL_DATA);
this.$router.push({name: ROUTE_NAMES_AUTH.LOGIN});
},
deleteAccount: function () {
setTimeout(this.logout, 50);
return this.$store.dispatch(DELETE_USER_ACCOUNT);
},