Skip to main content

FormData

The FormData interface provides a way to construct a set of key/value pairs representing form fields and their values, which can be sent using the fetch(), XMLHttpRequest.send() or navigator.sendBeacon() methods. It uses the same format a form would use if the encoding type were set to "multipart/form-data".

MDN Reference

Methods​

[iterator]()​

iterator: FormDataIterator<[string, FormDataEntryValue]>;

Returns​

FormDataIterator<[string, FormDataEntryValue]>


append()​

Call Signature​

append(name, value): void;

The append() method of the FormData interface appends a new value onto an existing key inside a FormData object, or adds the key if it does not already exist.

MDN Reference

Parameters​
ParameterType
namestring
valuestring | Blob
Returns​

void

Call Signature​

append(name, value): void;
Parameters​
ParameterType
namestring
valuestring
Returns​

void

Call Signature​

append(
name,
blobValue,
filename?
): void;
Parameters​
ParameterType
namestring
blobValueBlob
filename?string
Returns​

void


delete()​

delete(name): void;

The delete() method of the FormData interface deletes a key and its value(s) from a FormData object.

MDN Reference

Parameters​

ParameterType
namestring

Returns​

void


entries()​

entries(): FormDataIterator<[string, FormDataEntryValue]>;

Returns an array of key, value pairs for every entry in the list.

Returns​

FormDataIterator<[string, FormDataEntryValue]>


forEach()​

forEach(callbackfn, thisArg?): void;

Parameters​

ParameterType
callbackfn(value, key, parent) => void
thisArg?any

Returns​

void


get()​

get(name): FormDataEntryValue | null;

The get() method of the FormData interface returns the first value associated with a given key from within a FormData object. If you expect multiple values and want all of them, use the getAll() method instead.

MDN Reference

Parameters​

ParameterType
namestring

Returns​

FormDataEntryValue | null


getAll()​

getAll(name): FormDataEntryValue[];

The getAll() method of the FormData interface returns all the values associated with a given key from within a FormData object.

MDN Reference

Parameters​

ParameterType
namestring

Returns​

FormDataEntryValue[]


has()​

has(name): boolean;

The has() method of the FormData interface returns whether a FormData object contains a certain key.

MDN Reference

Parameters​

ParameterType
namestring

Returns​

boolean


keys()​

keys(): FormDataIterator<string>;

Returns a list of keys in the list.

Returns​

FormDataIterator<string>


set()​

Call Signature​

set(name, value): void;

The set() method of the FormData interface sets a new value for an existing key inside a FormData object, or adds the key/value if it does not already exist.

MDN Reference

Parameters​
ParameterType
namestring
valuestring | Blob
Returns​

void

Call Signature​

set(name, value): void;
Parameters​
ParameterType
namestring
valuestring
Returns​

void

Call Signature​

set(
name,
blobValue,
filename?
): void;
Parameters​
ParameterType
namestring
blobValueBlob
filename?string
Returns​

void


values()​

values(): FormDataIterator<FormDataEntryValue>;

Returns a list of values in the list.

Returns​

FormDataIterator<FormDataEntryValue>