Marvin Irwin
Marvin Irwin

Reputation: 1010

Read all bytes from a ReadableStream

I'd like to load an entire fetch response in one go, but there doesn't seem to be a readAll or similar function.

What is the most performant way to read every byte from a ReadableStreamDefaultReader into a single Uint8Array?

Upvotes: 5

Views: 4707

Answers (1)

Daniel A. White
Daniel A. White

Reputation: 190941

Fetch's Response interface has .arrayBuffer() which returns an ArrayBuffer.

Upvotes: 9

Related Questions