@exromany/lido-csm-sdk
Version:
[](https://github.com/lidofinance/lido-csm-sdk/blob/main/LICENSE.txt) [](h
20 lines • 782 B
TypeScript
export type FetchFn<T> = (url: string) => Promise<T | null>;
export type ParseFn<T> = (text: string) => T;
export type ValidateFn<T> = (data: T) => boolean;
type Fetcher = <T>(url: string, params?: RequestInit, parse?: ParseFn<T>) => Promise<T>;
export declare const fetchJson: Fetcher;
export declare const fetchWithFallback: <T>(urls: Array<string | null>, fetch: FetchFn<T>) => Promise<NonNullable<Awaited<T>> | void>;
type FetchOneOfProps<T> = {
urls: Array<string | null>;
validate?: ValidateFn<T>;
} & ({
fetch?: FetchFn<T>;
parse?: never;
} | {
fetch?: never;
parse?: ParseFn<T>;
});
type FetchOneOf = <T>(props: FetchOneOfProps<T>) => Promise<T | void>;
export declare const fetchOneOf: FetchOneOf;
export {};
//# sourceMappingURL=fetch-json.d.ts.map