fix(nuxt): omit the body from useFetch for GET requests (nuxt#20667)

This commit is contained in:
Connor van Spronssen 2025-01-06 21:23:07 +01:00
parent 728b7e1c25
commit 5d82bbaa7a

View File

@ -27,18 +27,22 @@ interface NitroFetchOptions<R extends NitroFetchRequest, M extends AvailableRout
type ComputedFetchOptions<R extends NitroFetchRequest, M extends AvailableRouterMethod<R>> = ComputedOptions<NitroFetchOptions<R, M>> type ComputedFetchOptions<R extends NitroFetchRequest, M extends AvailableRouterMethod<R>> = ComputedOptions<NitroFetchOptions<R, M>>
export interface UseFetchOptions< export type UseFetchOptions<
ResT, ResT,
DataT = ResT, DataT = ResT,
PickKeys extends KeysOf<DataT> = KeysOf<DataT>, PickKeys extends KeysOf<DataT> = KeysOf<DataT>,
DefaultT = undefined, DefaultT = undefined,
R extends NitroFetchRequest = string & {}, R extends NitroFetchRequest = string & {},
M extends AvailableRouterMethod<R> = AvailableRouterMethod<R>, M extends AvailableRouterMethod<R> = AvailableRouterMethod<R>,
> extends Omit<AsyncDataOptions<ResT, DataT, PickKeys, DefaultT>, 'watch'>, ComputedFetchOptions<R, M> { > = Omit<AsyncDataOptions<ResT, DataT, PickKeys, DefaultT>, 'watch'> &
key?: string (M extends 'GET' | 'get'
$fetch?: typeof globalThis.$fetch ? Omit<ComputedFetchOptions<R, M>, 'body'>
watch?: MultiWatchSources | false : ComputedFetchOptions<R, M>
} ) & {
key?: string
$fetch?: typeof globalThis.$fetch
watch?: MultiWatchSources | false
}
/** /**
* Fetch data from an API endpoint with an SSR-friendly composable. * Fetch data from an API endpoint with an SSR-friendly composable.