pinia custom plugin undefined
Hey there i have a custom fetch function from the docs https://nuxt.com/docs/guide/recipes/custom-usefetch but when declaring it inside the global store context of a pinia store its undefined, in the function scope it is not. But i dont really wanna call the
useNuxtApp()
composable everytime I fetch:
Do you have any regards why?
Thanks!5 Replies
Apparently its not initialized yet, even tho i named the plugin 01.apiFetch.ts - any solutions to this?
Configure the plugin dependency option if you want to initialize the plugin after it is loaded I.e.
dependsOn: ['pinia']
Otherwise just define a composable and use that for simplicity.Thanks for the answer, unfortuantely its the other way around, pinia should wait for the plugin. I tried out your solution and $apiFetch is undefined
I havent found anything to let pinia wait on other plugins
Have you tried the more simplistic avenue of creating a composable? If it needs to be a plugin to, just provide the api from the composable.
Thanks for trying to help me, I have a composable for a custom useFetch:
You suggest creating another composable instead of the plugin?