N
Nuxt5mo ago
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,
}
}
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?
1 Reply
Creep
CreepOP5mo ago
Nothing from the custom useFetch/useAsyncData seems to work either 🤔
Nuxt
Custom useFetch in Nuxt · Recipes
How to create a custom fetcher for calling your external API in Nuxt 3.
Want results from more Discord servers?
Add your server