-
Notifications
You must be signed in to change notification settings - Fork 2k
/
Copy pathfetch.d.ts
121 lines (97 loc) · 2.95 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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
import { Agent as HttpAgent } from 'http';
import { Agent as HttpsAgent } from 'https';
export declare function fetch(
input: RequestInfo,
init?: RequestInit,
): Promise<Response>;
export type RequestAgent = HttpAgent | HttpsAgent;
export type RequestInfo = Request | string;
export declare class Headers implements Iterable<[string, string]> {
constructor(init?: HeadersInit);
append(name: string, value: string): void;
delete(name: string): void;
get(name: string): string | null;
has(name: string): boolean;
set(name: string, value: string): void;
entries(): Iterator<[string, string]>;
keys(): Iterator<string>;
values(): Iterator<string>;
[Symbol.iterator](): Iterator<[string, string]>;
}
export type HeadersInit = Headers | string[][] | { [name: string]: string };
export declare class Body {
readonly bodyUsed: boolean;
arrayBuffer(): Promise<ArrayBuffer>;
json(): Promise<any>;
text(): Promise<string>;
}
export declare class Request extends Body {
constructor(input: Request | string, init?: RequestInit);
readonly method: string;
readonly url: string;
readonly headers: Headers;
clone(): Request;
}
export interface RequestInit {
method?: string;
headers?: HeadersInit;
body?: BodyInit;
mode?: RequestMode;
credentials?: RequestCredentials;
cache?: RequestCache;
redirect?: RequestRedirect;
referrer?: string;
referrerPolicy?: ReferrerPolicy;
integrity?: string;
// The following properties are node-fetch extensions
follow?: number;
timeout?: number;
compress?: boolean;
size?: number;
agent?: RequestAgent | false;
// Cloudflare Workers accept a `cf` property to control Cloudflare features
// See https://developers.cloudflare.com/workers/reference/cloudflare-features/
cf?: {
[key: string]: any;
};
}
export type RequestMode = 'navigate' | 'same-origin' | 'no-cors' | 'cors';
export type RequestCredentials = 'omit' | 'same-origin' | 'include';
export type RequestCache =
| 'default'
| 'no-store'
| 'reload'
| 'no-cache'
| 'force-cache'
| 'only-if-cached';
export type RequestRedirect = 'follow' | 'error' | 'manual';
export type ReferrerPolicy =
| ''
| 'no-referrer'
| 'no-referrer-when-downgrade'
| 'same-origin'
| 'origin'
| 'strict-origin'
| 'origin-when-cross-origin'
| 'strict-origin-when-cross-origin'
| 'unsafe-url';
export declare class Response extends Body {
constructor(body?: BodyInit, init?: ResponseInit);
static error(): Response;
static redirect(url: string, status?: number): Response;
readonly url: string;
readonly redirected: boolean;
readonly status: number;
readonly ok: boolean;
readonly statusText: string;
readonly headers: Headers;
clone(): Response;
}
export interface ResponseInit {
headers?: HeadersInit;
status?: number;
statusText?: string;
// Although this isn't part of the spec, `node-fetch` accepts a `url` property
url?: string;
}
export type BodyInit = ArrayBuffer | ArrayBufferView | string;