mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-22 20:39:17 +08:00
Added Headers constructor options to whatwg-fetch (#10313)
This commit is contained in:
committed by
Masahiro Wakame
parent
73291dad15
commit
d997f92b89
@@ -1,5 +1,18 @@
|
||||
/// <reference path="whatwg-fetch.d.ts" />
|
||||
|
||||
function test_HeadersCopiedFromHeaders() {
|
||||
var source = new Headers();
|
||||
source.append('Content-Type', 'application/json');
|
||||
return new Headers(source);
|
||||
}
|
||||
|
||||
function test_HeadersCopiedFromHash() {
|
||||
var source:HeadersMap = {
|
||||
'Content-Type': 'application/json'
|
||||
};
|
||||
return new Headers(source);
|
||||
}
|
||||
|
||||
function test_fetchUrlWithOptions() {
|
||||
var headers = new Headers();
|
||||
headers.append("Content-Type", "application/json");
|
||||
|
||||
6
whatwg-fetch/whatwg-fetch.d.ts
vendored
6
whatwg-fetch/whatwg-fetch.d.ts
vendored
@@ -41,7 +41,12 @@ type RequestCache =
|
||||
"default" | "no-store" | "reload" | "no-cache" |
|
||||
"force-cache" | "only-if-cached";
|
||||
|
||||
declare interface HeadersMap {
|
||||
[index: string]: string;
|
||||
}
|
||||
|
||||
declare class Headers {
|
||||
constructor(headers?:Headers|HeadersMap)
|
||||
append(name: string, value: string): void;
|
||||
delete(name: string):void;
|
||||
get(name: string): string;
|
||||
@@ -60,6 +65,7 @@ declare class Body {
|
||||
json<T>(): Promise<T>;
|
||||
text(): Promise<string>;
|
||||
}
|
||||
|
||||
declare class Response extends Body {
|
||||
constructor(body?: BodyInit, init?: ResponseInit);
|
||||
static error(): Response;
|
||||
|
||||
Reference in New Issue
Block a user