18 lines
422 B
TypeScript
18 lines
422 B
TypeScript
import type { NitroFetchRequest } from 'nitropack'
|
|
|
|
export function $api<
|
|
T = unknown,
|
|
R extends NitroFetchRequest = NitroFetchRequest,
|
|
>(
|
|
request: Parameters<typeof $fetch<T, R>>[0],
|
|
options?: Partial<Parameters<typeof $fetch<T, R>>[1]>,
|
|
) {
|
|
const runtimeConfig = useRuntimeConfig()
|
|
|
|
return $fetch<T, R>(request, {
|
|
...options,
|
|
retry: false,
|
|
baseURL: runtimeConfig.public.apiHost as string,
|
|
})
|
|
}
|