tsbase
Version:
Base class libraries for TypeScript
18 lines (17 loc) • 1.23 kB
TypeScript
import { IHttpClient, RestResponse } from './IHttpClient';
import { HttpMethod } from './HttpMethod';
export type Fetch = (input: RequestInfo, init?: RequestInit) => Promise<Response>;
export declare class HttpClient implements IHttpClient {
DefaultRequestHeaders: Record<string, string>;
protected fetchRef: Fetch;
OnRequestReceived?: ((request: Request) => Promise<Response | Request>) | undefined;
OnResponseResolved?: (response: Response) => void;
constructor(DefaultRequestHeaders?: Record<string, string>, fetchRef?: Fetch);
Request(uri: string, method: HttpMethod, body?: string, additionalHeaders?: Record<string, string>): Promise<Response>;
Get<T>(uri: string, additionalHeaders?: Record<string, string>): Promise<RestResponse<T>>;
Patch<T>(uri: string, body?: string, additionalHeaders?: Record<string, string>): Promise<RestResponse<T>>;
Post<T>(uri: string, body?: string, additionalHeaders?: Record<string, string>): Promise<RestResponse<T>>;
Put<T>(uri: string, body?: string, additionalHeaders?: Record<string, string>): Promise<RestResponse<T>>;
Delete<T>(uri: string, additionalHeaders?: Record<string, string>): Promise<RestResponse<T>>;
private getRestResponse;
}