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:
export const useUserStore = defineStore("userStore", (context) => {
// Global Store scope
const nuxtApp = useNuxtApp()
console.log(nuxtApp.$apiFetch); // undefined
async function Fetch() {
// function scope
const nuxtApp = useNuxtApp()
await nuxtApp.$apiFetch() // working
}
});
Do you have any regards why?
Thanks!