custom uselazyfetch
codes below are my custom usefetch, how to make a uselazyfetch?
import type { UseFetchOptions } from '#app'
export const useAPI = <T>(
url: string | (() => string),
options?: UseFetchOptions<T>,
) => {
return useFetch(url, {
...options,
$fetch: useNuxtApp().$api as typeof $fetch,
})
}
import type { UseFetchOptions } from '#app'
export const useAPI = <T>(
url: string | (() => string),
options?: UseFetchOptions<T>,
) => {
return useFetch(url, {
...options,
$fetch: useNuxtApp().$api as typeof $fetch,
})
}
