UNPKG

rest-fetcher

Version:
53 lines (52 loc) 1.64 kB
export interface FetcherConfig { baseUrl: string; defaultTimeout?: number; credentialsMode?: RequestCredentials; defaultHeaders?: {}; } export declare class Fetcher { constructor(config: FetcherConfig); private baseUrl; private defaultTimeout; private defaultHeaders; private credentialsMode; /** * Send GET REST API call * @param apiEndpoint * @param params * @param timeout */ get(apiEndpoint: string, params?: any, timeout?: number, headers?: any): Promise<any>; /** * Send POST REST API call * @param apiEndpoint * @param params * @param timeout */ post(apiEndpoint: string, params?: any, timeout?: number, headers?: any): Promise<any>; /** * Send PUT REST API call * @param apiEndpoint * @param params * @param timeout */ put(apiEndpoint: string, params?: any, timeout?: number, headers?: any): Promise<any>; /** * Send PATCH REST API call * @param apiEndpoint * @param params * @param timeout */ pathc(apiEndpoint: string, params?: any, timeout?: number, headers?: any): Promise<any>; /** * Send DELETE REST API call * @param apiEndpoint * @param params * @param timeout */ delete(apiEndpoint: string, params?: any, timeout?: number, headers?: any): void; private doRequest(apiEndpoint, requestObj?, timeout?, headers?); private callRestMethod(apiEndpoint, method, timeout, params?, headers?); private saveBlobToFile(blob); private normalizeError(errMessage); }