@focuson/utils
Version:
Common utilities for the @focuson project
20 lines (19 loc) • 1.26 kB
TypeScript
/** This is a wrapper for the javascript fetch function. The input parameters are the same as for fetch. The output is the statuscode and a T, where T is the expected json type
*
* T is probably not meaningful if the status code is not a 2xx
* */
export declare function setIsNodeFetchForTests(): void;
export declare var isNode: boolean;
export declare function delay(ms: number): Promise<unknown>;
export interface FetchFn {
(re: RequestInfo, init?: RequestInit): Promise<[number, any]>;
}
/** Normally we would use the defaultFetchFn or the loggingFetchFn */
export declare const defaultFetchFn: <T>(re: RequestInfo, init?: RequestInit) => Promise<[number, T]>;
/** Normally we would use the defaultFetchFn or the loggingFetchFn */
export declare function loggingFetchFn<T>(re: RequestInfo, init?: RequestInit): Promise<[number, T]>;
/** Normally we would use the defaultFetchFn or the loggingFetchFn */
export declare function loggingResultFetchFn<T>(re: RequestInfo, init?: RequestInit): Promise<[number, T]>;
export declare function fetchWithPrefix(prefix: string, fetchFn: FetchFn): FetchFn;
export declare function fetchWithDelay(ms: number, fetchFn: FetchFn): FetchFn;
export declare function loadingCursorFetch(fetchFn: FetchFn): FetchFn;