files/en-us/web/api/formdata/get/index.md
{{APIRef("XMLHttpRequest API")}} {{AvailableInWorkers}}
The get() method of the {{domxref("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
{{domxref("FormData.getAll()","getAll()")}} method instead.
get(name)
name
A value whose key matches the specified name. Otherwise, null.
If we add two username values to a {{domxref("FormData")}} using {{domxref("FormData.append", "append()")}}:
formData.append("username", "Chris");
formData.append("username", "Bob");
The following get() method will only return the first username value:
formData.get("username"); // Returns "Chris"
{{Specifications}}
{{Compat}}