Response: formData() method

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since March 2017.

Note: This feature is available in Web Workers.

The formData() method of the Response interface takes a Response stream and reads it to completion. It returns a promise that resolves with a 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

js
formData()

Parameters

None.

Return value

A Promise that resolves with a FormData object.

Exceptions

DOMException AbortError

The request was aborted.

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 Content-Encoding header is incorrect).
  • The MIME type of the body cannot be determined from the Content-Type headers included in the response.
  • The body cannot be parsed as a FormData object.

Examples

TBD.

Specifications

Specification
Fetch
# ref-for-dom-body-formdata①

Browser compatibility

Report problems with this compatibility data on GitHub
desktopmobileserver
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
Deno
Node.js
formData

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
Partial support
Partial support
Has more compatibility info.

See also