Interface RequestOptions

Allows customizing the fetch RequestInit options, as well as setting the type of response

interface RequestOptions {
    responseType?: ResponseType;
    throwHttpErrors?: boolean;
}

Hierarchy (View Summary)

Properties

responseType?: ResponseType

specify body type when decoding. Use 'stream' to skip parsing body completely

Options are:

  • undefined (default): autodetect - object if json response (most common), text if text response type, otherwise a ReadableStream
  • 'json': return a json object (most common type of response)
  • 'text': return as string
  • 'blob': return as a Blob
  • 'stream': return the response.body as-is with no processing (may be NodeJS Readable if using node-fetch polyfill)
  • 'webstream': return response.body as a ReadableStream
  • 'nativestream': return response.body as a NodeJS Readable stream if using node, otherwise ReadableStream
throwHttpErrors?: boolean

whether to throw errors or not for HTTP error response codes.

true