Interface FetchConfigLoaderOptions

Options for the FetchConfigLoader

interface FetchConfigLoaderOptions {
    cache: undefined | IRequestCache;
    cacheHitHttpCode: number;
    disabled?: boolean | Promise<boolean> | () => boolean | Promise<boolean>;
    fetchClient: {
        (input: URL | RequestInfo, init?: RequestInit): Promise<Response>;
        (input: string | URL | Request, init?: RequestInit): Promise<Response>;
    };
    isSilent: boolean;
    logger: undefined
    | ILoggerLike;
    payload: "json";
    validate:
        | undefined
        | ValidateCallback<
            Record<string, undefined | string>,
            Record<string, undefined | string>,
        >;
}

Hierarchy (View Summary)

Properties

cache: undefined | IRequestCache
cacheHitHttpCode: number

if we get a cache hit code (defaults 304), we use the cached response instead

disabled?: boolean | Promise<boolean> | () => boolean | Promise<boolean>
fetchClient: {
    (input: URL | RequestInfo, init?: RequestInit): Promise<Response>;
    (input: string | URL | Request, init?: RequestInit): Promise<Response>;
}

Type declaration

    • (input: URL | RequestInfo, init?: RequestInit): Promise<Response>
    • Parameters

      • input: URL | RequestInfo
      • Optionalinit: RequestInit

      Returns Promise<Response>

    • (input: string | URL | Request, init?: RequestInit): Promise<Response>
    • Parameters

      • input: string | URL | Request
      • Optionalinit: RequestInit

      Returns Promise<Response>

isSilent: boolean

this prevents Error to be thrown if have http error

logger: undefined | ILoggerLike
payload: "json"
validate:
    | undefined
    | ValidateCallback<
        Record<string, undefined | string>,
        Record<string, undefined | string>,
    >

optional validator for JSON response (Record<string, string | undefined>)

// using zod
const stringRecordSchema = z.record(z.string().min(1), z.string());
const validate: ValidateCallback<Record<string, string>> = async (data) => {
const result = await stringRecordSchema.safeParseAsync(data);
if (!result.success) {
return {success: false, message: result.error.message};
}
return {success: true};
};