forked from queicherius/lets-fetch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fetch.d.ts
26 lines (26 loc) · 1.12 KB
/
fetch.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import _fetch from 'cross-fetch';
import Bluebird from 'bluebird';
import LetsWrap, { ILetsWrapOptions } from '../..';
export interface IFetch {
request: typeof _fetch;
}
export declare const enum EnumResponseType {
response = "response",
json = "json",
text = "text"
}
export interface ILetsWrapFetchOptions<T = EnumResponseType.response | EnumResponseType.text | EnumResponseType.json | string | 'text' | 'json' | 'response'> extends ILetsWrapOptions<IFetch, RequestInit> {
/**
* response type, can be "json", "text" or "response"
*/
type?: T;
http?: IFetch;
}
export declare class LetsWrapFetch extends LetsWrap<IFetch, ILetsWrapFetchOptions> {
constructor(options?: ILetsWrapFetchOptions);
single<T = Response>(url: string, options?: ILetsWrapFetchOptions<EnumResponseType | string>): Bluebird<T>;
many<T extends unknown[] = Response[]>(urls: string[], options?: ILetsWrapFetchOptions): Bluebird<T>;
requestOptions(options: ILetsWrapFetchOptions): Partial<RequestInit>;
request<T = Response>(url: string, options?: ILetsWrapFetchOptions): Bluebird<T>;
}
export default LetsWrapFetch;