Problem getting data from Pinia
I have a component used within my layout that is responsible for setting user information. However, when I try to access this user info from another component located deeper in the component tree, it returns null.
navbar.vue
test.vue
i logged them and it seems the problem is that test.vue runs before navbar.vue
file structure
- dashboardLayout
-- navbar.vue // -> getting data here
-- TestLayout
--- AComponent.vue
---- Test.vue // -> runs here
5 Replies
Check out the
storeToRefs
composable. https://pinia.vuejs.org/core-concepts/#Destructuring-from-a-StorePinia 🍍
Intuitive, type safe, light and flexible Store for Vue
info
will be a ref
so will update once the data is populated.i'll check it out thanks
@Mediv0 did you get it working? I'm having a similar issue, I think
Not yet
I just moved the shared logic to my main layout