@trophyso/node
Version:
NodeJS SDK for the Trophy API
36 lines (35 loc) • 1.11 kB
TypeScript
import { APIResponse } from "./APIResponse";
export declare type FetchFunction = <R = unknown>(args: Fetcher.Args) => Promise<APIResponse<R, Fetcher.Error>>;
export declare namespace Fetcher {
interface Args {
url: string;
method: string;
contentType?: string;
headers?: Record<string, string | undefined>;
queryParameters?: Record<string, string | string[]>;
body?: unknown;
timeoutMs?: number;
maxRetries?: number;
withCredentials?: boolean;
responseType?: "json" | "blob" | "streaming";
}
type Error = FailedStatusCodeError | NonJsonError | TimeoutError | UnknownError;
interface FailedStatusCodeError {
reason: "status-code";
statusCode: number;
body: unknown;
}
interface NonJsonError {
reason: "non-json";
statusCode: number;
rawBody: string;
}
interface TimeoutError {
reason: "timeout";
}
interface UnknownError {
reason: "unknown";
errorMessage: string;
}
}
export declare const fetcher: FetchFunction;