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

28 lines
1.1 KiB
TypeScript
Raw Normal View History

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