Dmitriy Pleshevskiy
49aac94675
chore: add dist folder to repo chore(deps): add node-fetch for tests chore: change prepare request visibility chore: add tests for prepare request method chore: update example Closes #20
23 lines
838 B
TypeScript
23 lines
838 B
TypeScript
import { Method } from './endpoint';
|
|
export declare type ClientConfig = {
|
|
baseUrl: string;
|
|
};
|
|
declare type PrepareRequestProps = {
|
|
url: string;
|
|
method: Method;
|
|
headers: Record<string, string>;
|
|
variables: Record<string, any> | FormData;
|
|
};
|
|
export declare type RequestProps<R> = PrepareRequestProps & {
|
|
transformResponseData?: (data: unknown) => R;
|
|
};
|
|
export declare type ClientResponse<Data extends Record<string, any>> = Readonly<Pick<Response, 'ok' | 'redirected' | 'status' | 'statusText' | 'type' | 'headers' | 'url'> & {
|
|
data: Data;
|
|
}>;
|
|
export declare class Client {
|
|
private config;
|
|
constructor(config: ClientConfig);
|
|
private prepareRequest;
|
|
request<Data extends Record<string, any>>({ transformResponseData, ...restProps }: RequestProps<Data>): Promise<ClientResponse<Data>>;
|
|
}
|
|
export {};
|