kawkab-frontend
Version:
Kawkab frontend is a frontend library for the Kawkab framework
25 lines (24 loc) • 930 B
TypeScript
import { AxiosRequestConfig } from 'axios';
export interface ApiClientConfig {
baseURL: string;
getToken: () => string | null;
}
export interface RequestOptions {
headers?: Record<string, string>;
body?: any;
}
export declare class ApiError extends Error {
status?: number;
data: any;
constructor(message: string, status?: number, data?: any);
}
export declare class ApiClient {
private axiosInstance;
constructor(config: ApiClientConfig);
private handleResponse;
get<T = any>(endpoint: string, config?: AxiosRequestConfig): Promise<T>;
post<T = any>(endpoint: string, body: any, config?: AxiosRequestConfig): Promise<T>;
put<T = any>(endpoint: string, body: any, config?: AxiosRequestConfig): Promise<T>;
patch<T = any>(endpoint: string, body: any, config?: AxiosRequestConfig): Promise<T>;
delete<T = any>(endpoint: string, config?: AxiosRequestConfig): Promise<T>;
}