Created
September 8, 2016 19:01
-
-
Save jribeiro/154467aab4bcb9430b1824cbc7117396 to your computer and use it in GitHub Desktop.
An attempt to create a flowtype definition for the fetchAPI
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// flow-typed signature: 11e550b72570f3e50044485062a42c26 | |
// flow-typed version: 33aa7c82cd/isomorphic-fetch_v2.x.x/flow_>=v0.27.x | |
declare type $Fetch$RequestMode = 'cors' | 'no-cors' | 'cors-with-forced-preflight' | 'same-origin' | 'navigate'; | |
declare type $Fetch$RequestCredentials = 'omit' | 'same-origin' | 'include'; | |
declare type $Fetch$RequestRedirect = 'follow' | 'error' | 'manual'; | |
declare type $Fetch$RequestCache = 'default' | 'no-store' | 'reload' | 'no-cache' | 'force-cache'; | |
declare type $Fetch$ResponseType = 'basic' | 'cors' | 'error' | 'opaque'; | |
declare type $Fetch$ReferrerPolicy = 'no-referrer' | 'no-referrer-when-downgrade' | 'origin' | | |
'origin-when-cross-origin' | 'unsafe-url'; | |
declare class $Fetch$Headers { | |
Headers(): $Fetch$Headers; | |
append(name: string, value: any): void; | |
delete(name: string): void; | |
entries(): Iterator<*>; | |
get(name: string): string; | |
getAll(name: string): Array<string>; | |
has(name: string): Boolean; | |
keys(): Iterator<string>; | |
set(name: string, value: any): void; | |
values(): Iterator<*>; | |
} | |
declare class $Fetch$Body { | |
bodyUsed: Boolean; | |
arrayBuffer(): Promise<ArrayBuffer>; | |
blob(): Promise<Blob>; | |
formData(): Promise<FormData>; | |
json(): Promise<JSON>; | |
text(): Promise<string>; | |
} | |
declare class $Fetch$Request mixins $Fetch$Body { | |
Request(): $Fetch$Request; | |
clone(): $Fetch$Request; | |
method: string; | |
url: string; | |
headers: $Fetch$Headers; | |
referrer: string; | |
referrerPolicy: string; | |
mode: $Fetch$RequestMode; | |
credentials: $Fetch$RequestCredentials; | |
redirect: $Fetch$RequestRedirect; | |
integrity: string; | |
cache: $Fetch$RequestCache; | |
} | |
declare type $Fetch$Options = { | |
method?: string, | |
headers?: $Fetch$Headers, | |
body?: Blob | ArrayBuffer | FormData | URLSearchParams | string, | |
mode?: $Fetch$RequestMode | Object, | |
credentials?: $Fetch$RequestCredentials, | |
cache?: $Fetch$RequestCache, | |
redirect?: $Fetch$RequestRedirect, | |
referrer?: string, | |
referrerPolicy?: $Fetch$ReferrerPolicy, | |
integrity?: string, | |
} | |
declare class $Fetch$Response mixins $Fetch$Body { | |
Response(): $Fetch$Response; | |
clone(): $Fetch$Response; | |
error(): $Fetch$Response; | |
redirect(url: string, status?: number): $Fetch$Response; | |
headers: $Fetch$Headers; | |
ok: Boolean; | |
redirected: Boolean; | |
status: number; | |
statusText: string; | |
type: $Fetch$ResponseType; | |
url: string; | |
} | |
declare var fetch: (url: string, options?: $Fetch$Options) => Promise<$Fetch$Response>; | |
declare module 'isomorphic-fetch' { | |
declare module.exports: fetch; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment