Back to Content

FormData: entries() method

files/en-us/web/api/formdata/entries/index.md

latest1012 B
Original Source

{{APIRef("XMLHttpRequest API")}} {{AvailableInWorkers}}

The FormData.entries() method returns an iterator which iterates through all key/value pairs contained in the {{domxref("FormData")}}. The key of each pair is a string, and the value is either a string or a {{domxref("Blob")}}.

Syntax

js-nolint
entries()

Parameters

None.

Return value

An iterator of {{domxref("FormData")}}'s key/value pairs.

Examples

js
formData.append("key1", "value1");
formData.append("key2", "value2");

// Display the key/value pairs
for (const pair of formData.entries()) {
  console.log(pair[0], pair[1]);
}

The result is:

plain
key1 value1
key2 value2

Specifications

{{Specifications}}

Browser compatibility

{{Compat}}

See also