UNPKG

api-wizard

Version:

A powerful TypeScript wrapper for native Fetch API with token management, interceptors, and type-safe HTTP requests

52 lines (51 loc) 1.77 kB
import { FetchClient } from './interfaces/Http.js'; import { FetchResponse, FetchRequestConfig } from './interfaces/Fetch.js'; interface AxiosCompatibleError extends Error { response?: { data: any; status: number; statusText: string; headers: any; }; request?: any; config?: any; status?: number; _retry?: boolean; } export declare class FetchError extends Error implements AxiosCompatibleError { response?: { data: any; status: number; statusText: string; headers: any; }; request?: any; config?: any; status: number; _retry?: boolean; constructor(status: number, statusText: string, originalResponse: Response, url: string, data?: any, requestConfig?: any); } export declare class FetchClientImpl implements FetchClient { private baseURL; private defaultHeaders; private defaultConfig; private defaultValidateStatus; constructor(config?: { baseURL?: string; headers?: HeadersInit; requestConfig?: RequestInit; validateStatus?: (status: number) => boolean; }); private buildURL; private mergeHeaders; private transformResponse; request<T>(config: FetchRequestConfig & { url: string; }): Promise<FetchResponse<T>>; get<T>(url: string, config?: FetchRequestConfig): Promise<FetchResponse<T>>; post<T>(url: string, data?: any, config?: FetchRequestConfig): Promise<FetchResponse<T>>; put<T>(url: string, data?: any, config?: FetchRequestConfig): Promise<FetchResponse<T>>; patch<T>(url: string, data?: any, config?: FetchRequestConfig): Promise<FetchResponse<T>>; delete<T>(url: string, config?: FetchRequestConfig): Promise<FetchResponse<T>>; } export {};