base_ui/composables/useApi.ts
2025-05-18 14:24:11 +03:30

12 lines
239 B
TypeScript

import type { UseFetchOptions } from 'nuxt/app'
export function useApi<T>(
url: string | (() => string),
options?: UseFetchOptions<T>,
) {
return useFetch(url, {
...options,
$fetch: useNuxtApp().$api as typeof $fetch
})
}