import type { Ref } from '@stacksjs/stx'; /** * Chainable reactive fetch composable. Pass the expected success body * shape as the type argument to get a typed `data.value`. * * @example * ```ts * interface Post { id: number, title: string } * const { error, data } = await useFetch('/api/posts').get().json() * // data: Ref * const { data } = await useFetch('/api/posts').post(JSON.stringify(body)).json() * const { error } = await useFetch('/api/posts/1').delete().json() * ``` */ export declare function useFetch(url: string): FetchBuilder; /** * Result of a terminal `.json()` call. Generic over the success body * `T` (stacksjs/stacks#1924) so `data.value` is typed instead of * `any`. `error` stays `unknown` — it can be a parsed error body OR a * thrown network error, so the caller should narrow before use. */ export declare interface UseFetchResult { data: Ref error: Ref isFetching: Ref then: (resolve: (value: { data: Ref, error: Ref }) => void) => Promise } export declare interface FetchBuilder { get: () => FetchBuilder post: (body?: string) => FetchBuilder patch: (body?: string) => FetchBuilder put: (body?: string) => FetchBuilder delete: () => FetchBuilder json: () => UseFetchResult }