One issue I am facing is with my store module for current user. After logging into the app, I store user data in it. However, upon logging out and being redirected to the login page, I remove the current-user data from local storage.
Interestingly, following the logout process, a console error appears:
Cannot read property 'id' of null
This error stems from how I have configured values in my current user module:
const currentUser = {
state: {
id: JSON.parse(localStorage.getItem('current-user')).id || '',
username: JSON.parse(localStorage.getItem('current-user')).username || '',
},
The issue occurs because the code attempts to access the local storage object that no longer exists after deletion during the log out process. I'm seeking advice on the best approach to address this problem as I am relatively new to working with Vue and uncertain if my current implementation is appropriate.