FormData

open class FormData(form: EventTarget = definedExternally, submitter: EventTarget? = definedExternally) : MapLike.Mixin<JsString, FormDataEntryValue> , BodyInit(source)

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

Constructors

Link copied to clipboard
constructor(form: EventTarget = definedExternally, submitter: EventTarget? = definedExternally)

Functions

Link copied to clipboard
open external fun append(name: String, value: String)
open external fun append(name: String, value: Blob)

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.

open external fun append(name: String, blobValue: Blob, filename: String = definedExternally)
Link copied to clipboard
open external fun delete(name: String)

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

Link copied to clipboard
open external override fun entries(): JsIterator<Tuple2<JsString, FormDataEntryValue>>
Link copied to clipboard
open external override fun forEach(action: (value: FormDataEntryValue, JsString) -> Unit)
Link copied to clipboard
open external fun get(name: String): FormDataEntryValue?

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.

Link copied to clipboard
open external fun getAll(name: String): ReadonlyArray<FormDataEntryValue>

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

Link copied to clipboard
open external fun has(name: String): Boolean

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

Link copied to clipboard
open external override fun keys(): JsIterator<JsString>
Link copied to clipboard
open external fun set(name: String, value: String)
open external fun set(name: String, value: Blob)

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.

open external fun set(name: String, blobValue: Blob, filename: String = definedExternally)
Link copied to clipboard
open external override fun values(): JsIterator<FormDataEntryValue>