1 | import { Agent as HttpAgent } from 'http';
|
2 | import { Agent as HttpsAgent } from 'https';
|
3 |
|
4 | export declare function fetch(
|
5 | input: RequestInfo,
|
6 | init?: RequestInit,
|
7 | ): Promise<Response>;
|
8 |
|
9 | export type RequestAgent = HttpAgent | HttpsAgent;
|
10 |
|
11 | export type RequestInfo = Request | string;
|
12 |
|
13 | export declare class Headers implements Iterable<[string, string]> {
|
14 | constructor(init?: HeadersInit);
|
15 |
|
16 | append(name: string, value: string): void;
|
17 | delete(name: string): void;
|
18 | get(name: string): string | null;
|
19 | has(name: string): boolean;
|
20 | set(name: string, value: string): void;
|
21 |
|
22 | entries(): Iterator<[string, string]>;
|
23 | keys(): Iterator<string>;
|
24 | values(): Iterator<string>;
|
25 | [Symbol.iterator](): Iterator<[string, string]>;
|
26 | }
|
27 |
|
28 | export type HeadersInit = Headers | string[][] | { [name: string]: string };
|
29 |
|
30 | export declare class Body {
|
31 | readonly bodyUsed: boolean;
|
32 | arrayBuffer(): Promise<ArrayBuffer>;
|
33 | json(): Promise<any>;
|
34 | text(): Promise<string>;
|
35 | }
|
36 |
|
37 | export declare class Request extends Body {
|
38 | constructor(input: Request | string, init?: RequestInit);
|
39 |
|
40 | readonly method: string;
|
41 | readonly url: string;
|
42 | readonly headers: Headers;
|
43 |
|
44 | clone(): Request;
|
45 | }
|
46 |
|
47 | export interface RequestInit {
|
48 | method?: string;
|
49 | headers?: HeadersInit;
|
50 | body?: BodyInit;
|
51 | mode?: RequestMode;
|
52 | credentials?: RequestCredentials;
|
53 | cache?: RequestCache;
|
54 | redirect?: RequestRedirect;
|
55 | referrer?: string;
|
56 | referrerPolicy?: ReferrerPolicy;
|
57 | integrity?: string;
|
58 |
|
59 |
|
60 | follow?: number;
|
61 | timeout?: number;
|
62 | compress?: boolean;
|
63 | size?: number;
|
64 | agent?: RequestAgent | false;
|
65 |
|
66 |
|
67 |
|
68 | cf?: {
|
69 | [key: string]: any;
|
70 | };
|
71 | }
|
72 |
|
73 | export type RequestMode = 'navigate' | 'same-origin' | 'no-cors' | 'cors';
|
74 |
|
75 | export type RequestCredentials = 'omit' | 'same-origin' | 'include';
|
76 |
|
77 | export type RequestCache =
|
78 | | 'default'
|
79 | | 'no-store'
|
80 | | 'reload'
|
81 | | 'no-cache'
|
82 | | 'force-cache'
|
83 | | 'only-if-cached';
|
84 |
|
85 | export type RequestRedirect = 'follow' | 'error' | 'manual';
|
86 |
|
87 | export type ReferrerPolicy =
|
88 | | ''
|
89 | | 'no-referrer'
|
90 | | 'no-referrer-when-downgrade'
|
91 | | 'same-origin'
|
92 | | 'origin'
|
93 | | 'strict-origin'
|
94 | | 'origin-when-cross-origin'
|
95 | | 'strict-origin-when-cross-origin'
|
96 | | 'unsafe-url';
|
97 |
|
98 | export declare class Response extends Body {
|
99 | constructor(body?: BodyInit, init?: ResponseInit);
|
100 | static error(): Response;
|
101 | static redirect(url: string, status?: number): Response;
|
102 |
|
103 | readonly url: string;
|
104 | readonly redirected: boolean;
|
105 | readonly status: number;
|
106 | readonly ok: boolean;
|
107 | readonly statusText: string;
|
108 | readonly headers: Headers;
|
109 |
|
110 | clone(): Response;
|
111 | }
|
112 |
|
113 | export interface ResponseInit {
|
114 | headers?: HeadersInit;
|
115 | status?: number;
|
116 | statusText?: string;
|
117 |
|
118 | url?: string;
|
119 | }
|
120 |
|
121 | export type BodyInit = ArrayBuffer | ArrayBufferView | string;
|