@wizecorp/stratusjs
Version:
Stratus React Framework
43 lines • 1.44 kB
TypeScript
import type { HttpService as IHttpService, RequestConfig } from '../types';
/**
* HTTP service for making API calls
*/
export declare class HttpService implements IHttpService {
readonly name = "HttpService";
private baseURL;
private defaultHeaders;
private timeout;
constructor(options?: {
baseURL?: string;
defaultHeaders?: Record<string, string>;
timeout?: number;
});
get<T = any>(url: string, config?: RequestConfig): Promise<T>;
post<T = any>(url: string, data?: any, config?: RequestConfig): Promise<T>;
put<T = any>(url: string, data?: any, config?: RequestConfig): Promise<T>;
delete<T = any>(url: string, config?: RequestConfig): Promise<T>;
patch<T = any>(url: string, data?: any, config?: RequestConfig): Promise<T>;
private request;
private buildURL;
/**
* Set default headers for all requests
*/
setDefaultHeaders(headers: Record<string, string>): void;
/**
* Set authorization header
*/
setAuthToken(token: string, type?: 'Bearer' | 'Basic'): void;
/**
* Remove authorization header
*/
clearAuthToken(): void;
}
/**
* HTTP Error class
*/
export declare class HttpError extends Error {
status?: number | undefined;
response?: Response | undefined;
constructor(message: string, status?: number | undefined, response?: Response | undefined);
}
//# sourceMappingURL=HttpService.d.ts.map