This repository has been archived on 2023-03-02. You can view files and clone it, but cannot push or open issues or pull requests.
react-rest-request/target/client.d.ts

29 lines
1 KiB
TypeScript
Raw Normal View History

import { Method } from './endpoint';
2021-06-15 00:11:58 +03:00
export interface ClientConfig {
baseUrl: string;
2021-06-15 00:11:58 +03:00
}
export interface PrepareRequestProps {
url: string;
method: Method;
headers: Record<string, string>;
variables: Record<string, any> | FormData;
2021-06-15 00:11:58 +03:00
}
export declare type RequestProps<R> = PrepareRequestProps & {
transformResponseData?: (data: unknown) => R;
};
export declare type ResponseWithError = Pick<Response, 'ok' | 'redirected' | 'status' | 'statusText' | 'type' | 'headers' | 'url'> & Readonly<{
error?: Error;
canceled?: boolean;
}>;
export declare type ClientResponse<Data extends Record<string, any>> = ResponseWithError & Readonly<{
data: Data;
}>;
export declare class Client {
2021-06-15 00:11:58 +03:00
private readonly config;
private controller;
constructor(config: ClientConfig);
2020-12-08 10:40:55 +03:00
prepareRequest(props: PrepareRequestProps): Request;
request<Data extends Record<string, any>>({ transformResponseData, ...restProps }: RequestProps<Data>): Promise<ClientResponse<Data>>;
cancelRequest(): void;
}