Skip to content

Type Alias: ResponseBodyType ​

ResponseBodyType = "auto" | "json" | "text" | "binary" | "blob" | "stream" | "ndjson"

Defined in: api/rust-fetch.d.ts:53

How to decode the response body:

  • auto (default): JSON for application/json and *+json, text for text/* and XML, otherwise Uint8Array
  • json: always JSON.parse (fails with a ParseError if the body isn't JSON)
  • text: always a string
  • binary: always a Uint8Array
  • stream: a ReadableStream<Uint8Array>, returned as soon as the headers arrive
  • ndjson: a ReadableStream of parsed JSON values, one per line of newline-delimited JSON, returned as soon as the headers arrive

Empty bodies are null for auto/json, "" for text and an empty Uint8Array for binary. blob is a Blob typed with the response's Content-Type (an empty one for an empty body).

Released under the MIT or Apache-2.0 license.