Class “FormData”

Object > FormData

FormData provides a way to construct a set of key/value pairs which can then be sent using fetch() or XMLHttpRequest. It uses the same format a HTML form would use if the encoding type were set to multipart/form-data.

Constructor public
Singleton No
Namespace global
Direct subclasses None
JSX support No

Constructor

new FormData()

Methods

append(key, value)

Adds a string value associated with a given key. Any existing values for that key will be retained.

Parameter Type Optional Description
key string No  
value string No  

Returns void

append(key, value, filename?)

Adds binary data associated with a given key. Will be stored as an instance of File with its name set to the given filename parameter. If no filename is given and the value is not already a named File instance it will default to 'blob'. Any existing values for that key will be retained.

Parameter Type Optional Description
key string No  
value Blob | File No  
filename string Yes  

Returns void

delete(key)

Removes all values associated with a given key.

Parameter Type Optional Description
key string No  

Returns void

entries()

Returns IterableIterator<[string, string | File]>

get(key)

Returns the first value associated with a given key.

Parameter Type Optional Description
key string No  

Returns string | File | null

getAll(key)

Returns all the values associated with a given key.

Parameter Type Optional Description
key string No  

Returns Array<string | File>

has(key)

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

Parameter Type Optional Description
key string No  

Returns boolean

keys()

Returns IterableIterator<string>

set(key, value)

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

Parameter Type Optional Description
key string No  
value string No  

Returns void

set(key, value, filename?)

Adds binary data associated with a given key. Will be stored as an instance of File with its name set to the given filename parameter. If no filename is given and the value is not already a named File instance it will default to 'blob'. Any existing values for that key will be replaced.

Parameter Type Optional Description
key string No  
value Blob | File No  
filename string Yes  

Returns void

values()

Returns IterableIterator<string | File>