const headers = new Headers(init?: object | Array<[string, string]> | Headers);
Parameter Name | Type | Required | Description |
init | No | Initialize the Headers object. The parameter types are described as follows: object The constructor will enumerate all enumerable properties contained in Object and initialize them into a new Headers object. Array<[string, string]> Each element in the array is a key-value pair. Example: [key, value]. The Constructor API traverses the array and pre-populates the key-value pairs to the new Headers object. Headers Copies the Headers object and initializes all fields into a new Headers object. |
headers.append(name: string, value: string): void;
Headers object. If the header does not exist, the append() method directly adds the header.headers object has the following write-in limits:Property Name | Type | Required | Description |
name | string | Yes | header name |
value | string | Yes | New value to append |
headers.delete(name: string): void;
Headers object.Property Name | Type | Required | Description |
name | string | Yes | header name |
headers.entries(): iterator;
Headers object. The key-value pairs are in the format of [name, value]. For valid return values, see Iteration protocols.headers.forEach(callback: (name: string, value: string) => void | number): void;
Headers object. If callback returns a non-zero value, traversal is stopped.headers.get(name: string): string;
Headers object.headers.getSetCookie(): Array<string>
headers.has(name: string): boolean;
Headers object contains the specified header.headers.keys(): iterator;
Headers object. For valid return values, see Iteration protocols.headers.set(name: string, value: string): void;
Headers object. If the header does not exist, the set() method directly adds the header.headers object has the following write-in limits:headers.values(): iterator;
Headers object. For valid return values, see Iteration protocols.function handleEvent() {const headers = new Headers({'my-header-x': 'hello world',});const response = new Response('hello world', {headers,});return response;}addEventListener('fetch', (event) => {event.respondWith(handleEvent(event));});
Apakah halaman ini membantu?
Anda juga dapat Menghubungi Penjualan atau Mengirimkan Tiket untuk meminta bantuan.
masukan