Js.FormData
Bindings to FormData
The values returned by the `get,All
` and iteration functions is either a string or a Blob. Melange uses an abstract type and defers to users of the API to handle it according to their application needs.
let make: unit => t;
make ()
creates a new FormData
object, initially empty.
let append:
name:string =>
value:[ `String(string) | `Object(Js.t({.. })) | `Dict(Js.dict(_)) ] =>
t =>
unit;
append t ~name ~value
appends a new value onto an existing key inside a FormData object, or adds the key if it does not already exist.
let appendBlob:
name:string =>
value:[ `Blob(Js.blob) | `File(Js.file) ] =>
?filename:string =>
t =>
unit;
appendBlob t ~name ~value
appends a new value onto an existing key inside a FormData object, or adds the key if it does not already exist. This method differs from append
in that instances in the Blob hierarchy can pass a third filename argument.
let delete: name:string => t => unit;
delete t ~name
deletes a key and its value(s) from a FormData object.
let get: name:string => t => option(entryValue);
get t ~name
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 getAll
instead.
let getAll: name:string => t => array(entryValue);
getAll t ~name
returns all the values associated with a given key from within a FormData object.
let set:
name:string =>
[ `String(string) | `Object(Js.t({.. })) | `Dict(Js.dict(_)) ] =>
t =>
unit;
set t ~name ~value
sets a new value for an existing key inside a FormData object, or adds the key/value if it does not already exist.
setBlob t ~name ~value ?filename
sets a new value for an existing key inside a FormData object, or adds the key/value if it does not already exist. This method differs from set
in that instances in the Blob hierarchy can pass a third filename argument.
let has: name:string => t => bool;
has ~name t
returns whether a FormData object contains a certain key.
let keys: t => Js.iterator(string);
keys t
returns an iterator which iterates through all keys contained in the FormData. The keys are strings.
let values: t => Js.iterator(entryValue);
values t
returns an iterator which iterates through all values contained in the FormData. The values are strings or Blob objects.
let entries: t => Js.iterator((string, entryValue));
entries t
returns an iterator which iterates through all key/value pairs contained in the FormData.