UNPKG

1.41 kBTypeScriptView Raw
1import 'isomorphic-fetch';
2export interface IResponse<T> {
3 ok: boolean;
4 status: number;
5 statusText?: string;
6 type: string;
7 url: string;
8 data?: T;
9}
10export interface IHttpHeaders {
11 [id: string]: string;
12}
13declare function get<T>(url: string, headers?: IHttpHeaders): Promise<IResponse<T>>;
14declare function put<T>(url: string, data?: object, headers?: IHttpHeaders): Promise<IResponse<T>>;
15declare function post<T>(url: string, data?: object, headers?: IHttpHeaders): Promise<IResponse<T>>;
16declare function patch<T>(url: string, data?: object, headers?: IHttpHeaders): Promise<IResponse<T>>;
17declare function del<T>(url: string, headers?: IHttpHeaders): Promise<IResponse<T>>;
18declare function headers(httpHeaders: IHttpHeaders): {
19 get: <T>(url: string) => Promise<IResponse<T>>;
20 put: <T>(url: string, data?: object | undefined) => Promise<IResponse<T>>;
21 post: <T>(url: string, data?: object | undefined) => Promise<IResponse<T>>;
22 patch: <T>(url: string, data?: object | undefined) => Promise<IResponse<T>>;
23 delete: <T>(url: string) => Promise<IResponse<T>>;
24 headers: (append: IHttpHeaders) => any;
25};
26export { get, put, post, patch, del as delete, headers };
27declare const _default: {
28 get: typeof get;
29 put: typeof put;
30 post: typeof post;
31 patch: typeof patch;
32 delete: typeof del;
33 headers: typeof headers;
34};
35export default _default;