Provides a way to easily construct a set of key/value pairs representing form fields and their values, which can then be easily sent using fetch().

Hierarchy

  • FormData

Constructors

Properties

[iterator]: (() => SpecIterableIterator<[string, FormDataEntryValue]>)

Type declaration

[toStringTag]: string
entries: (() => SpecIterableIterator<[string, FormDataEntryValue]>)

Type declaration

forEach: ((callbackfn, thisArg?) => void)

Type declaration

    • (callbackfn, thisArg?): void
    • Executes given callback function for each field of the FormData instance

      Parameters

      • callbackfn: ((value, key, iterable) => void)
      • Optional thisArg: unknown

      Returns void

keys: (() => SpecIterableIterator<string>)

Type declaration

Type declaration

Methods

  • Appends a new value onto an existing key inside a FormData object, or adds the key if it does not already exist.

    The difference between set() and append() is that if the specified key already exists, set() will overwrite all existing values with the new one, whereas append() will append the new value onto the end of the existing set of values.

    Parameters

    • name: string

      The name of the field whose data is contained in value.

    • value: unknown

      The field's value. This can be Blob or File. If none of these are specified the value is converted to a string.

    • Optional fileName: string

      The filename reported to the server, when a Blob or File is passed as the second parameter. The default filename for Blob objects is "blob". The default filename for File objects is the file's filename.

    Returns void

  • Deletes a key and its value(s) from a FormData object.

    Parameters

    • name: string

      The name of the key you want to delete.

    Returns void

  • 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.

    Parameters

    • name: string

      A name of the value you want to retrieve.

    Returns null | FormDataEntryValue

    A FormDataEntryValue containing the value. If the key doesn't exist, the method returns null.

  • Returns all the values associated with a given key from within a FormData object.

    Parameters

    • name: string

      A name of the value you want to retrieve.

    Returns FormDataEntryValue[]

    An array of FormDataEntryValue whose key matches the value passed in the name parameter. If the key doesn't exist, the method returns an empty list.

  • Returns a boolean stating whether a FormData object contains a certain key.

    Parameters

    • name: string

      A string representing the name of the key you want to test for.

    Returns boolean

    A boolean value.

  • Set a new value for an existing key inside FormData, or add the new field if it does not already exist.

    Parameters

    • name: string

      The name of the field whose data is contained in value.

    • value: unknown

      The field's value. This can be Blob or File. If none of these are specified the value is converted to a string.

    • Optional fileName: string

      The filename reported to the server, when a Blob or File is passed as the second parameter. The default filename for Blob objects is "blob". The default filename for File objects is the file's filename.

    Returns void

Generated using TypeDoc