import { type Signal } from "solid-js"; import type { ApiError, UrlOptions } from "../../types/index.js"; /** Reactive state exposed by the {@link useRequest} primitive (Solid accessors). */ export interface RequestState { data: Signal[0]; error: Signal[0]; loading: Signal[0]; refetch: () => Promise; } /** * Solid primitive that wraps KatanaKit's HTTP GET with fine-grained signals. * Bridges the Safe Result pattern to idiomatic Solid state and never throws * on HTTP errors. * * Stale responses are ignored via a request version counter and AbortController; * in-flight requests are aborted on cleanup. * * @param apiName - Name of the registered API (see `useInitApis`). * @param endpointName - Name of the endpoint inside that API. * @param options - Optional `UrlOptions` (path/query params). * @returns Signal accessors `{ data, error, loading }` plus `refetch`. * * @example * ```tsx * import { Show } from "solid-js"; * import { useRequest } from "katanakit-js/adapters/solid"; * * function Pokemon() { * const { data, error, loading } = useRequest<{ name: string }>( * "pokeapi", * "pokemonById", * { params: { id: 25 } }, * ); * return ( * Loading…}> *
{data()?.name}
*
* ); * } * ``` */ export declare function useRequest(apiName: string, endpointName: string, options?: UrlOptions): RequestState; //# sourceMappingURL=fetch.d.ts.map