# Response: formData() method



The **`formData()`** method of the [Response](https://developer.mozilla.org/en-US/docs/Web/API/Response) interface
takes a [Response](https://developer.mozilla.org/en-US/docs/Web/API/Response) stream and reads it to completion. It returns a promise
that resolves with a [FormData](https://developer.mozilla.org/en-US/docs/Web/API/FormData) object.

> **NOTE:**
> This is mainly relevant to [service workers](https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API). 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-nolint
formData()
```

### Parameters

None.

### Return value

A [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) that resolves with a [FormData](https://developer.mozilla.org/en-US/docs/Web/API/FormData) object.

### Exceptions

- `AbortError` [DOMException](https://developer.mozilla.org/en-US/docs/Web/API/DOMException)
  - : The request was [aborted](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch#canceling_a_request).
- [TypeError](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypeError)
  - : Thrown for one of the following reasons:
    - The response body is [disturbed or locked](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch#locked_and_disturbed_streams).
    - There was an error decoding the body content (for example, because the [Content-Encoding](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Encoding) header is incorrect).
    - The [MIME](https://developer.mozilla.org/en-US/docs/Glossary/MIME) type of the body cannot be determined from the [Content-Type](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/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

## Browser compatibility

## See also

- [ServiceWorker API](https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API)
- [HTTP access control (CORS)](https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/CORS)
- [HTTP](https://developer.mozilla.org/en-US/docs/Web/HTTP)
