NuxtN
Nuxt2y ago
1 reply
Creep

Passing useFetch types onward

Trying to expand the useFetch to refresh api data upon receiving update from the server by doing stuff like this
export default function syncFetch(url: string, opts = {}) {
    const ws = useWsStore()
    const ret = useFetch(url, opts)
    
    if (process.client) {
        ws.addTrack(url, ret.refresh)
        console.log("TRACKING", url)
    }
    
    return {
        ...ret,
        data: ret.data,
    }
}

everything works nice and fine except the data shows as Ref<unknown> on the other end instead of the automatically inferred useFetch type, is there anything i can do about this?
Was this page helpful?