Skip to content

Latest commit

 

History

History
62 lines (43 loc) · 1.8 KB

index.md

File metadata and controls

62 lines (43 loc) · 1.8 KB
title short-title slug page-type browser-compat
Response: formData() method
formData()
Web/API/Response/formData
web-api-instance-method
api.Response.formData

{{APIRef("Fetch API")}}

The formData() method of the {{domxref("Response")}} interface takes a {{domxref("Response")}} stream and reads it to completion. It returns a promise that resolves with a {{domxref("FormData")}} object.

Note

This is mainly relevant to service workers. If a user submits a form and a service worker intercepts the request, you could for example call formData() on it to obtain a key-value map, modify some fields, then send the form onwards to the server (or use it locally).

Syntax

formData()

Parameters

None.

Return value

A {{jsxref("Promise")}} that resolves with a {{domxref("FormData")}} object.

Exceptions

  • {{domxref("DOMException")}} AbortError
  • {{jsxref("TypeError")}}
    • : Thrown for one of the following reasons:
      • The response body is disturbed or locked.
      • There was an error decoding the body content (for example, because the {{httpheader("Content-Encoding")}} header is incorrect).
      • The {{glossary("MIME")}} type of the body cannot be determined from the {{httpheader("Content-Type")}} headers included in the response.
      • The body cannot be parsed as a FormData object.

Examples

TBD.

Specifications

{{Specifications}}

Browser compatibility

{{Compat}}

See also