Web APIs

Response.blob()

Try the free JavaScript compiler

Read the whole response into a Blob, using available Content-Type metadata. Do not rely on metadata alone to validate untrusted file contents. Example console output: 3 text/plain.

Formal Syntax & Structure

javascript syntaxjavascript
response.blob()

Return Value

Promise<Blob>

Blob containing body bytes.

Working Example

Example Snippetjavascript
(async () => {const response=new Response("abc",{headers:{"Content-Type":"text/plain"}}); const blob=await response.blob(); console.log(blob.size,blob.type);})()
JavaScript Reference