Creep
Creep
NNuxt
Created by Creep on 8/10/2024 in #❓・help
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?
2 replies