UNPKG

@ashraflabs/use-api

Version:

A simple and powerful custom React hook (useApi) that simplifies API requests with automatic loading and error states. Ideal for clean and maintainable data fetching in React components.

19 lines (18 loc) 691 B
/** * A custom error class for Fetch API errors, including HTTP and network errors. * @example * throw new FetchError("HTTP error! Status: 404", response, 404); */ export declare class FetchError extends Error { /** The Fetch API Response object, if available. */ response: Response | null; /** The HTTP status code, if applicable. */ status: number | null; /** * Creates a new FetchError instance. * @param message The error message. * @param response The Fetch API Response object, if available. * @param status The HTTP status code, if applicable. */ constructor(message: string, response?: Response | null, status?: number | null); }