Jul 15, 2024
0
Level 63
Access a reactive property from inside a pinia store
Hello,
I have an authStore in which I have the authenticated user properties.
const authUser = reactive({});
function setAuthUser(user) {
authUser.id = user.id;
authUser.name = user.name;
authUser.email = user.email;
authUser.admin = user.admin;
authUser.manage_branches = user.manage_branches;
isAuthenticated.value = true;
}
And I use this store in a component.
The use is authenticated.
console.log(authStore.authUser); // I get a proxy object with all right datas about the connected user (id: 1, ...)
console.log(authStore.authUser.id); // I get undefined
Do you have any idea what could be the problem ?
Thanks for your help.
V
Please or to participate in this conversation.