Skip to main content

DenchConfig

Summary

A configuration type used internally by request builders to manage the URL, RequestInit, error callback, timeout, and cancellation controller.

Type Definition

interface DenchOptions extends RequestInit {
method: string;
credentials?: HTTPCredentials;
signal?: AbortSignal;
headers?: Record<string, string>;
body?: BodyInit;
cache?: HTTPCache;
mode?: HTTPMode;
redirect?: HTTPRedirect;
referrerPolicy?: HTTPReferrerPolicy;
}

interface DenchBaseConfig {
baseURL: string;
api: string;
errorcallback?: (error: unknown) => void;
URLNormalize: DenchURLNormalizeMode;
options: DenchOptions;
}

interface DenchConfig extends DenchBaseConfig {
abortController?: AbortController;
timeout?: number;
}

DenchConfig has no generics. DenchOptions and DenchBaseConfig are not publicly exported types, but are shown to explain the inherited properties.

Properties

PropertyTypeRequiredDescription
baseURLstringYesThe base portion of the request URL.
apistringYesThe API path appended to the base URL.
errorcallback(error: unknown) => voidNoCallback invoked when a request error occurs.
URLNormalizeDenchURLNormalizeModeYesURL normalization mode applied when executing the request.
optionsDenchOptionsYesThe RequestInit configuration passed to fetch().
abortControllerAbortControllerNoController used for cancellation and timeout handling.
timeoutnumberNoRequest timeout in milliseconds.

options Properties

PropertyTypeRequiredDescription
methodstringYesHTTP request method.
credentialsHTTPCredentialsNoFetch credentials policy.
signalAbortSignalNoRequest cancellation signal.
headersRecord<string, string>NoRequest headers.
bodyBodyInitNoRequest body.
cacheHTTPCacheNoHTTP cache policy.
modeHTTPModeNoRequest mode.
redirectHTTPRedirectNoRedirect handling policy.
referrerPolicyHTTPReferrerPolicyNoReferrer policy.

Because DenchOptions extends RequestInit, native RequestInit properties not listed in the table are also available at the type level.

Used By

  • Optional configuration parameter of denchfetcher(url, config?).
  • Used by the internal runfetch(), toJson(), and toFormData() execution functions.
  • Every request configuration method reads DenchConfig or returns a new configuration.
  • DenchBuilder.config is publicly typed as DenchBaseConfig, so abortController and timeout are not directly exposed by that property type.
import type { DenchConfig } from 'dench-fetch';