Wait until store is ready #2405
Replies: 1 comment 4 replies
-
You don't need to wait for the store to be loaded, you need to wait for the authentication to load the current user: |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello,
I am creating a website with Nuxt and have decided to use Pinia as a store. When creating a store object, the store has it's initial state. For example, I might have a store with the default state
{authenticated:false}
. When I want to check if the user is authenticated in a page, the code will look like this:The problem here is that the code runs before the store has loaded the data, which means that the user will always be redirected to the login page.
Is there some way I can find out if the store has loaded, or I am still using the initial state?
Beta Was this translation helpful? Give feedback.
All reactions