@nahkies/typescript-fetch-runtime
Version:
Runtime package for code generated by @nahkies/openapi-code-generator using the typescript-fetch template
37 lines (36 loc) • 1.62 kB
TypeScript
import { type Encoding } from "./request-bodies/url-search-params";
import type { AbstractFetchClientConfig, HeaderParams, HeadersInit, QueryParams, Res, StatusCode } from "./types";
export * from "./types";
export declare abstract class AbstractFetchClient {
protected readonly basePath: string;
protected readonly defaultHeaders: Record<string, string>;
protected readonly defaultTimeout: number | undefined;
protected constructor(config: AbstractFetchClientConfig);
protected _fetch<R extends Res<StatusCode, unknown>>(url: string, opts: RequestInit, timeout?: number | undefined): Promise<R>;
protected _query(params: QueryParams): string;
/**
* Combines headers for a request, with precedence
* 1. default headers
* 2. route level header parameters
* 3. raw request config (escape hatch)
*
* following these rules:
* - header values of `undefined` are skipped
* - header values of `null` will remove/delete any previously set headers
*
* Eg:
* Passing `Authorization: null` as a parameter, will clear out any
* default `Authorization` header.
*
* But passing `Authorization: undefined` as parameter will fallthrough
* to the default `Authorization` header.
*
* @param paramHeaders
* @param optsHeaders
* @protected
*/
protected _headers(paramHeaders?: HeaderParams, optsHeaders?: HeadersInit): Headers;
protected _requestBodyToUrlSearchParams(obj: Record<string, unknown>, encoding?: Record<string, Encoding>): URLSearchParams;
private setHeaders;
private headersAsArray;
}