Merge pull request #4050 from ksheedlo/whatwg-fetch-support-stringstring-headers

Add support for headers as object in whatwg-fetch
This commit is contained in:
Masahiro Wakame
2015-04-08 00:11:02 +09:00
2 changed files with 13 additions and 3 deletions
+11 -1
View File
@@ -11,6 +11,16 @@ function test_fetchUrlWithOptions() {
handlePromise(window.fetch("http://www.andlabs.net/html5/uCOR.php", requestOptions));
}
function test_fetchUrlWithHeadersObject() {
var requestOptions: RequestInit = {
method: "POST",
headers: {
'Content-Type': 'application/json'
}
};
handlePromise(window.fetch("http://www.andlabs.net/html5/uCOR.php", requestOptions));
}
function test_fetchUrl() {
handlePromise(window.fetch("http://www.andlabs.net/html5/uCOR.php"));
}
@@ -21,4 +31,4 @@ function handlePromise(promise: Promise<Response>) {
}).then((text) => {
console.log(text);
});
}
}
+2 -2
View File
@@ -19,7 +19,7 @@ declare class Request {
interface RequestInit {
method?: string;
headers?: HeaderInit;
headers?: HeaderInit|{ [index: string]: string };
body?: BodyInit;
mode?: RequestMode;
credentials?: RequestCredentials;
@@ -81,4 +81,4 @@ declare type RequestInfo = Request|string;
interface Window {
fetch(url: string, init?: RequestInit): Promise<Response>;
}
}