mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-08-20 12:00:53 +08:00
Merge pull request #5998 from subash-a/corrected-fetch-typedef
corrected fetch args to support Request
This commit is contained in:
@@ -28,6 +28,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<Response>) {
|
||||
promise.then((response) => {
|
||||
if (response.type === 'basis') {
|
||||
|
||||
Vendored
+1
-1
@@ -80,5 +80,5 @@ declare type BodyInit = Blob|FormData|string;
|
||||
declare type RequestInfo = Request|string;
|
||||
|
||||
interface Window {
|
||||
fetch(url: string, init?: RequestInit): Promise<Response>;
|
||||
fetch(url: string|Request, init?: RequestInit): Promise<Response>;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user