demo · v132

Fetch some bytes and inspect them, ergonomically

Pick a URL and a body method. arrayBuffer() returns an ArrayBuffer you have to wrap in a view. bytes() returns a Uint8Array directly. Both arrive, but the bytes() version is one fewer line and one fewer allocation.

checking support…

response.arrayBuffer() → new Uint8Array(buf)

byteLength
elapsed
type

first 256 bytes (hex)

response.bytes() (v132)

byteLength
elapsed
type

first 256 bytes (hex)

// Before
const buf = await response.arrayBuffer();
const view = new Uint8Array(buf);
const firstByte = view[0];

// After (Chrome 132+)
const view = await response.bytes();
const firstByte = view[0];

see also