|
| 1 | +// Generated by typings |
| 2 | +// Source: https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/d997f92b892040860145a9510504dff22f672a36/whatwg-fetch/whatwg-fetch.d.ts |
| 3 | +declareclassRequestextendsBody{ |
| 4 | +constructor(input:string|Request,init?:RequestInit); |
| 5 | +method:string; |
| 6 | +url:string; |
| 7 | +headers:Headers; |
| 8 | +context:RequestContext; |
| 9 | +referrer:string; |
| 10 | +mode:RequestMode; |
| 11 | +redirect:RequestRedirect; |
| 12 | +credentials:RequestCredentials; |
| 13 | +cache:RequestCache; |
| 14 | +} |
| 15 | + |
| 16 | +interfaceRequestInit{ |
| 17 | +method?:string; |
| 18 | +headers?:HeaderInit|{[index:string]:string}; |
| 19 | +body?:BodyInit; |
| 20 | +mode?:RequestMode; |
| 21 | +redirect?:RequestRedirect; |
| 22 | +credentials?:RequestCredentials; |
| 23 | +cache?:RequestCache; |
| 24 | +} |
| 25 | + |
| 26 | +typeRequestContext= |
| 27 | +"audio"|"beacon"|"cspreport"|"download"|"embed"| |
| 28 | +"eventsource"|"favicon"|"fetch"|"font"|"form"|"frame"| |
| 29 | +"hyperlink"|"iframe"|"image"|"imageset"|"import"| |
| 30 | +"internal"|"location"|"manifest"|"object"|"ping"|"plugin"| |
| 31 | +"prefetch"|"script"|"serviceworker"|"sharedworker"| |
| 32 | +"subresource"|"style"|"track"|"video"|"worker"| |
| 33 | +"xmlhttprequest"|"xslt"; |
| 34 | +typeRequestMode="same-origin"|"no-cors"|"cors"; |
| 35 | +typeRequestRedirect="follow"|"error"|"manual"; |
| 36 | +typeRequestCredentials="omit"|"same-origin"|"include"; |
| 37 | +typeRequestCache= |
| 38 | +"default"|"no-store"|"reload"|"no-cache"| |
| 39 | +"force-cache"|"only-if-cached"; |
| 40 | + |
| 41 | +declareinterfaceHeadersMap{ |
| 42 | +[index:string]:string; |
| 43 | +} |
| 44 | + |
| 45 | +declareclassHeaders{ |
| 46 | +constructor(headers?:Headers|HeadersMap) |
| 47 | +append(name:string,value:string):void; |
| 48 | +delete(name:string):void; |
| 49 | +get(name:string):string; |
| 50 | +getAll(name:string):Array<string>; |
| 51 | +has(name:string):boolean; |
| 52 | +set(name:string,value:string):void; |
| 53 | +forEach(callback:(value:string,name:string)=>void):void; |
| 54 | +} |
| 55 | + |
| 56 | +declareclassBody{ |
| 57 | +bodyUsed:boolean; |
| 58 | +arrayBuffer():Promise<ArrayBuffer>; |
| 59 | +blob():Promise<Blob>; |
| 60 | +formData():Promise<FormData>; |
| 61 | +json():Promise<any>; |
| 62 | +json<T>():Promise<T>; |
| 63 | +text():Promise<string>; |
| 64 | +} |
| 65 | + |
| 66 | +declareclassResponseextendsBody{ |
| 67 | +constructor(body?:BodyInit,init?:ResponseInit); |
| 68 | +staticerror():Response; |
| 69 | +staticredirect(url:string,status:number):Response; |
| 70 | +type:ResponseType; |
| 71 | +url:string; |
| 72 | +status:number; |
| 73 | +ok:boolean; |
| 74 | +statusText:string; |
| 75 | +headers:Headers; |
| 76 | +clone():Response; |
| 77 | +} |
| 78 | + |
| 79 | +typeResponseType="basic"|"cors"|"default"|"error"|"opaque"|"opaqueredirect"; |
| 80 | + |
| 81 | +interfaceResponseInit{ |
| 82 | +status:number; |
| 83 | +statusText?:string; |
| 84 | +headers?:HeaderInit; |
| 85 | +} |
| 86 | + |
| 87 | +declaretypeHeaderInit=Headers|Array<string>; |
| 88 | +declaretypeBodyInit=ArrayBuffer|ArrayBufferView|Blob|FormData|string; |
| 89 | +declaretypeRequestInfo=Request|string; |
| 90 | + |
| 91 | +interfaceWindow{ |
| 92 | +fetch(url:string|Request,init?:RequestInit):Promise<Response>; |
| 93 | +} |
| 94 | + |
| 95 | +declarevarfetch:typeofwindow.fetch; |