local-fake-api
Version:
A simple async local mock API without backend.
25 lines (24 loc) • 661 B
TypeScript
interface TApiResponse<T> {
success: boolean;
data?: T;
error?: unknown;
}
interface UseRestApiProps<T> {
queryId?: unknown;
apiCall: () => Promise<TApiResponse<T>>;
initValue?: T;
enabled?: boolean;
}
declare function useRestApi<T = unknown>({ queryId, apiCall, initValue, enabled, }: UseRestApiProps<T>): {
isLoading: boolean;
isError: boolean;
hasError: boolean;
success: boolean;
apiData: T | undefined;
apiError: unknown;
setApiData: import("react").Dispatch<import("react").SetStateAction<T | undefined>>;
run: () => void;
reCall: () => void;
redo: () => void;
};
export { useRestApi };