Request: bytes() method

Baseline 2025
Newly available

Since January 2025, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.

Note: This feature is available in Web Workers.

The bytes() method of the Request interface reads the request body and returns it as a promise that resolves with a Uint8Array.

Syntax

js
bytes()

Parameters

None.

Return value

A promise that resolves with a Uint8Array.

Exceptions

TypeError

Thrown for one of the following reasons:

RangeError

Thrown if there is a problem creating the associated ArrayBuffer (for example, if the data size is too large).

Examples

js
const myArray = new Uint8Array(10);

const request = new Request("/myEndpoint", {
  method: "POST",
  body: myArray,
});

request.bytes().then((buffer) => {
  // do something with the buffer sent in the request
});

Specifications

Specification
Fetch
# dom-body-bytes

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
bytes
Chrome – Full support
Chrome 132 (Release date: 2025-01-14)
footnote Full support
Edge – Full support
Edge 132 (Release date: 2025-01-17)
footnote Full support
Firefox – Full support
Firefox 128 (Release date: 2024-07-09)
footnote Full support
Opera – Full support
Opera 117 (Release date: 2025-02-13)
footnote Full support
Safari – Full support
Safari 18 (Release date: 2024-09-16)
footnote Full support
Chrome Android – Full support
Chrome Android 132 (Release date: 2025-01-14)
footnote Full support
Firefox for Android – Full support
Firefox for Android 128 (Release date: 2024-07-09)
footnote Full support
Opera Android – Full support
Opera Android 87 (Release date: 2025-01-22)
footnote Full support
Safari on iOS – Full support
Safari on iOS 18 (Release date: 2024-09-16)
footnote Full support
Samsung Internet – Full support
Samsung Internet 29 (Release date: 2025-10-25)
footnote Full support
WebView Android – Full support
WebView Android 132 (Release date: 2025-01-14)
footnote Full support
WebView on iOS – Full support
WebView on iOS 18 (Release date: 2024-09-16)
footnote Full support
Bun – Full support
Bun 1.1.9 (Release date: 2024-05-22)
footnote Full support
Deno – Full support
Deno 1.44 (Release date: 2024-05-30)
footnote Full support
Node.js – No support
Node.js 20.16 – 20.17 (Release date: 2024-07-24)
footnote Removed in 21 and later
Node.js – Full support
Node.js 22.3 (Release date: 2024-06-11)
footnote Full support

Legend

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

Full support
Full support
Has more compatibility info.

See also