Reputation: 605
I need to fill a currentUser object,with id, username, picture, etc.., in vue store from the local storage when i open the app, if there is a user in the local storage of course. I want to know the best way to acomplish this, so I can use that currentUser in all views and components. I'm sorry that there is no code because it is only a question. Using vue-router, vue-x. Thank you in advance.
Upvotes: 3
Views: 2430
Reputation: 1430
Old question, but the answer could be useful anyway.
I used vuex-persist
library to automatically save vuex state in local storage (others can be used, e.g. session storage).
So every operation could be done in vuex, without directly load from and save to local storage
Upvotes: 2