Writing a wrapper for useFetch

Hey! We'd like to write some helper wrappers for useFetch (for example to call Ghost CMS endpoints for posts, or pages, all with their own composable abstracted. I'm wondering how do you correctly type the fetch options? I just want to pass the type through
export default function useGhostData(url: string, options: UseFetchOptions) { // UseFetchOptions requires 6 params
const runtimeConfig = useRuntimeConfig()

return useFetch(`${runtimeConfig}${url}`, options)
}
export default function useGhostData(url: string, options: UseFetchOptions) { // UseFetchOptions requires 6 params
const runtimeConfig = useRuntimeConfig()

return useFetch(`${runtimeConfig}${url}`, options)
}
1 Reply
Reinier Kaper
Reinier KaperOP9mo ago
Oh, it's just passing in a generic, isn't it? 🤦‍♂️ export default function useGhostData<T>(url: string, options: UseFetchOptions<T>) { should do it
Want results from more Discord servers?
Add your server