Skip to content

Type Alias: FetchCustomOptions

FetchCustomOptions = object & FetchRetryOptions & TimeoutOptions<[]>

Defined in: packages/fetch/src/types/options.ts:45

Custom fetch options (not used by built-in fetch()

Type Declaration

abortCtrl?

optional abortCtrl: AbortController

An AbortController instance to control the request.

If not provided, a new instance is automatically created internally.

It is supported in addition to the standard signal. If both are provided, abortCtrl will be aborted when the signal aborts or when the request times out.

Recommendation:

  • For request timeout purposes, setting a timeout duration will be sufficient. Abort controller/signal is not needed.
  • Use abortCtrl instead of signal to prevent creating internal AbortController instance.

as?

optional as: FetchAs

Specify how the parse the result. To get raw response use FetchAs.response. Default: 'json'

body?

optional body: PostArgs[1]

errMsgs?

optional errMsgs: FetchErrMsgs

fetchFunc?

optional fetchFunc: FetchFunc

Custom fetch function to use instead of the global fetch. Useful for testing or using a different fetch implementation (e.g. node-fetch in older Node versions).

Default: globalThis.fetch

interceptors?

optional interceptors: FetchInterceptors

Interceptor/transformer callback executed at different stages of the request. See FetchInterceptors for more details.

validateUrl?

optional validateUrl: boolean

Whether to validate URL before making the request. Default: false