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