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.

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

See also:

JSX formdata.jsx [► Run in Playground]

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 Description
key string  
value string  

Returns: undefined

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 Description
key string  
value Blob | File  
filename string Optional.

Returns: undefined

delete(key)

Removes all values associated with a given key.

Parameter Type Description
key string  

Returns: undefined

entries()

Returns: IterableIterator<[string, string | File]>

get(key)

Returns the first value associated with a given key.

Parameter Type Description
key string  

Returns: string
| File
| null

getAll(key)

Returns all the values associated with a given key.

Parameter Type Description
key string  

Returns: string[]

has(key)

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

Parameter Type Description
key string  

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 Description
key string  
value string  

Returns: undefined

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 Description
key string  
value Blob | File  
filename string Optional.

Returns: undefined

values()

Returns: IterableIterator<string | File>