Response: formData() method

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

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

AbortError DOMException

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, or is not application/x-www-form-urlencoded or multipart/form-data.
  • The body cannot be parsed as a FormData object.

Examples

TBD.

Specifications

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

Browser compatibility

desktop mobile server
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
Bun
Deno
Node.js
formData
Chrome – Partial support
Chrome 60 (Release date: 2017-07-25)
footnote Partial support
footnote If the form data is empty, then Chrome throws TypeError: Failed to fetch. See bug 40065051 and bug 40764130.
Edge – Partial support
Edge 79 (Release date: 2020-01-15)
footnote Partial support
footnote If the form data is empty, then Edge throws TypeError: Failed to fetch. See bug 40065051 and bug 40764130.
Firefox – Full support
Firefox 39 (Release date: 2015-07-02)
footnote Full support
Opera – Partial support
Opera 47 (Release date: 2017-08-09)
footnote Partial support
footnote If the form data is empty, then Opera throws TypeError: Failed to fetch. See bug 40065051 and bug 40764130.
Safari – Partial support
Safari 10.1 – 14 (Release date: 2017-03-27)
footnote Partial support
footnote The method exists but always rejects with NotSupportedError. See bug 215671.
Safari – Full support
Safari 14.1 (Release date: 2021-04-26)
footnote Full support
Chrome Android – Partial support
Chrome Android 60 (Release date: 2017-08-01)
footnote Partial support
footnote If the form data is empty, then Chrome Android throws TypeError: Failed to fetch. See bug 40065051 and bug 40764130.
Firefox for Android – Full support
Firefox for Android 39 (Release date: 2015-07-02)
footnote Full support
Opera Android – Partial support
Opera Android 44 (Release date: 2017-12-11)
footnote Partial support
footnote If the form data is empty, then Opera Android throws TypeError: Failed to fetch. See bug 40065051 and bug 40764130.
Safari on iOS – Partial support
Safari on iOS 10.3 – 14 (Release date: 2017-03-27)
footnote Partial support
footnote The method exists but always rejects with NotSupportedError. See bug 215671.
Safari on iOS – Full support
Safari on iOS 14.5 (Release date: 2021-04-26)
footnote Full support
Samsung Internet – Partial support
Samsung Internet 8 (Release date: 2018-07-18)
footnote Partial support
footnote If the form data is empty, then Samsung Internet throws TypeError: Failed to fetch. See bug 40065051 and bug 40764130.
WebView Android – Partial support
WebView Android 60 (Release date: 2017-08-01)
footnote Partial support
footnote If the form data is empty, then WebView Android throws TypeError: Failed to fetch. See bug 40065051 and bug 40764130.
WebView on iOS – Partial support
WebView on iOS 10.3 – 14 (Release date: 2017-03-27)
footnote Partial support
footnote The method exists but always rejects with NotSupportedError. See bug 215671.
WebView on iOS – Full support
WebView on iOS 14.5 (Release date: 2021-04-26)
footnote Full support
Bun – Full support
Bun 1 (Release date: 2023-09-08)
footnote Full support
Deno – Full support
Deno 1 (Release date: 2020-05-13)
footnote Full support
Node.js – Full support
Node.js 18 (Release date: 2022-04-19)
footnote Full support

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