Skip to main content

Enumeration: FetchResultTypes

@sapphire/fetch.FetchResultTypes

The supported return types for the fetch method

Enumeration members

Blob

โ€ข Blob = "blob"

Returns only the body, as a Blob.

remark For NodeJS environment other FetchResultTypes are recommended, but you can use a Blob if you want to.

Defined in

projects/utilities/packages/fetch/src/lib/types.ts:22


Buffer

โ€ข Buffer = "buffer"

Returns only the body, as a Buffer.

remark Does not work in a Browser environment. For browsers use FetchResultTypes.Blob instead. If you use this type in a Browsers environment a {@link ReferenceError ReferenceError: Buffer is not defined} will be thrown!

Defined in

projects/utilities/packages/fetch/src/lib/types.ts:17


JSON

โ€ข JSON = "json"

Returns only the body, as JSON. Similar to Body.json().

You should provide your own type cast (either through the generic return type, or with as <type>) to the response to define the JSON structure, otherwise the result will be unknown.

Defined in

projects/utilities/packages/fetch/src/lib/types.ts:11


Result

โ€ข Result = "result"

Returns the entire response and doesn't parse the body in any way.

Defined in

projects/utilities/packages/fetch/src/lib/types.ts:30


Text

โ€ข Text = "text"

Returns only the body, as plain text. Similar to Body.text().

Defined in

projects/utilities/packages/fetch/src/lib/types.ts:26