Class “Headers”

Object > Headers

Represents a set of HTTP headers as used by fetch().

Type: Headers extends Object
Constructor: public
Singleton: No
Namespace: global
Direct subclasses: None
JSX Support: No

Constructor

new Headers(headers?)

Parameter Type Description
headers Headers
| Array<[string, string]>
| {[header]: string}
Optional.

Methods

append(name, value)

Adds a value to a given header. Any existing values for that header will be retained.

Parameter Type Description
name string  
value string  

Returns: undefined

delete(name)

Removes all values associated with a given header.

Parameter Type Description
name string  

Returns: undefined

entries()

Returns: IterableIterator<[string, string]>

forEach(callback)

Parameter Type Description
callback (value, name) => void  

Returns: undefined

get(name)

Returns the first value associated with a given header.

Parameter Type Description
name string  

Returns: string | null

getAll(name)

Returns all values associated with a given header.

Parameter Type Description
name string  

Returns: string[]

has(name)

Returns true if there are any values associated with a given header.

Parameter Type Description
name string  

Returns: boolean

keys()

Returns: IterableIterator<string>

set(name, value)

Adds a string value associated with a given header. Any existing values for that header will be replaced.

Parameter Type Description
name string  
value string  

Returns: undefined

values()

Returns: IterableIterator<string>