diff --git a/whatwg-fetch/whatwg-fetch-tests.ts b/whatwg-fetch/whatwg-fetch-tests.ts index 5248f5d1d..f2e2bce11 100644 --- a/whatwg-fetch/whatwg-fetch-tests.ts +++ b/whatwg-fetch/whatwg-fetch-tests.ts @@ -25,6 +25,17 @@ function test_fetchUrl() { handlePromise(window.fetch("http://www.andlabs.net/html5/uCOR.php")); } +function test_fetchUrlWithRequestObject() { + var requestOptions: RequestInit = { + method: "POST", + headers: { + 'Content-Type': 'application/json' + } + }; + var request: Request = new Request("http://www.andlabs.net/html5/uCOR.php", requestOptions); + handlePromise(window.fetch(request)); +} + function handlePromise(promise: Promise) { promise.then((response) => { return response.text(); diff --git a/whatwg-fetch/whatwg-fetch.d.ts b/whatwg-fetch/whatwg-fetch.d.ts index 9efd039b4..a39d204a2 100644 --- a/whatwg-fetch/whatwg-fetch.d.ts +++ b/whatwg-fetch/whatwg-fetch.d.ts @@ -80,5 +80,5 @@ declare type BodyInit = Blob|FormData|string; declare type RequestInfo = Request|string; interface Window { - fetch(url: string, init?: RequestInit): Promise; + fetch(url: string|Request, init?: RequestInit): Promise; }