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 an Uint8Array.
bytes()
None.
A promise that resolves with an Uint8Array.
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
});
| Specification |
|---|
| Fetch> # dom-body-bytes> |
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | |
bytes |
132 | 132 | 128 | 117 | 18 | 132 | 128 | 87 | 18 | No | 132 | 18 |
© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/Request/bytes