interface FetchResult { data: any; error: any; status?: number; ok?: boolean; } interface FetchConfig extends Omit { autoFetch?: boolean; callback?: (result: FetchResult) => void; /** * If `true`, the fetch will be invoked with `credentials: 'include'`. * String values from the standard `RequestCredentials` are also supported * (e.g. 'omit' | 'same-origin' | 'include'). */ credentials?: boolean | RequestCredentials; /** * Query parameters to append to GET requests. * Supports strings, numbers, booleans, arrays, and objects. * - Primitives (string, number, boolean) are converted to strings * - Arrays are repeated as multiple params with the same key * - Objects are JSON-stringified * - null and undefined values are skipped * * Example: { active: true, page: 1, tags: ['a', 'b'] } * Results in: ?active=true&page=1&tags=a&tags=b */ params?: Record; } interface Return { apiResult: API_RESULT | undefined; data: any; error: any; fetchNow: (url?: string, config?: FetchConfig) => void; loading: boolean; } declare enum API_RESULT { SUCCESS = "SUCCESS", ERROR = "ERROR" } declare const useFetch: (url: string, config?: FetchConfig, deps?: Array | Array) => Return; export { API_RESULT, type FetchConfig, type FetchResult, type Return, useFetch };