Web APIs

Response.arrayBuffer()

Try the free JavaScript compiler

Consume the entire body into an ArrayBuffer. Use streaming instead when the body size cannot be safely bounded. Example console output: 3 4.

Formal Syntax & Structure

javascript syntaxjavascript
response.arrayBuffer()

Return Value

Promise<ArrayBuffer>

Buffer holding response bytes.

Working Example

Example Snippetjavascript
(async () => {const response=new Response(new Uint8Array([2,4,6])); const b=await response.arrayBuffer(); console.log(b.byteLength,new Uint8Array(b)[1]);})()
JavaScript Reference