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()
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 }});
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!
Recent Announcements
Continue the conversation
Join the Discord to ask follow-up questions and connect with the community