NuxtN
Nuxt2y ago
6 replies
itmaster

How to I can make loading with useAsyncdata?

//composable/use-api.ts
export const useBaseFetch = <T>(url: string) => {    
    const { setLoading } = useStore()   
    const _fetch = useAsyncData(key, () => $fetch(urlWithQuery.value)
    watch(_fetch.pending, (v) => {    
        // console.log(v); // always false
        setLoading(v)
    })
    return _fetch;
}

pending value is always false
so I can't loading spinner
what is my wrong?
thanks
Was this page helpful?