UNPKG

@datalayer/core

Version:
76 lines (75 loc) 1.9 kB
/** * A wrapped error for a fetch response. */ export declare class RunResponseError extends Error { /** * Create a RunResponseError from a response, * handling the traceback and message as appropriate. * * @param response The response object. * * @returns A promise that resolves with a `RunResponseError` object. */ static create(response: Response): Promise<RunResponseError>; /** * Create a new response error. */ constructor(response: Response, message?: string, warnings?: undefined, errors?: undefined, exceptionMessage?: undefined, traceback?: string); /** * Warnings listed in the response. */ readonly warnings: string[]; /** * Errors listed in the response. */ readonly errors: string[]; /** * The response associated with the error. */ readonly response: Response; /** * The exception associated with the error. */ readonly exceptionMessage?: string; /** * The traceback associated with the error. */ readonly traceback: string; private static _defaultMessage; } /** * A wrapped error for a network error. */ export declare class NetworkError extends TypeError { /** * Create a new network error. */ constructor(original: TypeError); } export interface IRequestDatalayerAPIOptions { /** * URL to request */ url: string; /** * HTTP method */ method?: string; /** * JSON-serializable object */ body?: any; /** * Headers */ headers?: Record<string, string>; /** * Authorization bearer token */ token?: string; /** * Request abort signal. */ signal?: AbortSignal; } export declare function requestDatalayerAPI<T = any>({ url, method, body, token, signal, headers }: IRequestDatalayerAPIOptions): Promise<T>;