Pinia in Nuxt 3 composable error
I'm using
"@pinia/nuxt": "^0.4.2"
in "nuxt": "^3.3.2"
(SSR).
Pinia is registered in nuxtconfig/modules and works within my .vue
files.
I'm trying to create a composable function (useSupabaseApi.ts
) which will be used frequently throughout my app to interact with my store.
When I import and create the store const store = userStore()
, nuxt throws this error:
This happens whenever I put const store = userStore()
inside the export function or outside the export function. I've checked the nuxt docs but I'm not sure what I'm doing wrong here.![No description](https://cdn.answeroverflow.com/1092768529310289970/Clipboard02.jpg)
8 Replies
Unknown Userβ’2y ago
Message Not Public
Sign In & Join Server To View
All my imports use ~~ at the beginning, not sure. But all of them work, so no problem here. The return is inside
useSupabaseApi
, just one bracket slipped to the first line because I removed some stuff to make the code more readable.Full thing with better formatting
![No description](https://cdn.answeroverflow.com/1092789353757016064/Clipboard02.jpg)
Unknown Userβ’2y ago
Message Not Public
Sign In & Join Server To View
Yeah I did. When I set up the StackBlitz, I realized that the problem is probably that I'm importing
saveUserResults
(which imports the store) in a Nuxt server route. Is there a way to use pinia in server routes?Unknown Userβ’2y ago
Message Not Public
Sign In & Join Server To View
K thanks for your help!
Unknown Userβ’2y ago
Message Not Public
Sign In & Join Server To View