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
Dmitriy Pleshevskiy 49aac94675 fix: use window location as base url
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
2020-12-08 10:35:18 +03:00

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 {};