UNPKG

@nodescript/stdlib

Version:
31 lines (30 loc) 1.15 kB
export declare enum FetchResponseType { AUTO = "auto", JSON = "json", URL_ENCODED = "urlencoded", TEXT = "text", BINARY = "binary" } export declare enum FetchMethod { GET = "GET", POST = "POST", PUT = "PUT", DELETE = "DELETE", PATCH = "PATCH" } export declare function parseQueryString(qs: string): Record<string, string[]>; export declare function mergeUrlQuery(url: string, query: Record<string, string | undefined>): string; export declare function determineRequestBody(method: FetchMethod, body: any): [string | undefined, string | undefined]; export declare function readResponse(response: Response, type: FetchResponseType, contentType: string): Promise<any>; export declare function headersToObject(headers: Headers | Record<string, string | string[]>): Record<string, string[]>; export declare class HttpRequestFailed extends Error { name: string; details: {}; status: number; constructor(status: number, method: string, url: string, details: any); } export declare class FetchError extends Error { name: string; status: number; constructor(status: number, message: string); }