From 893fa691a74a011d59770e452874249dbef4ae18 Mon Sep 17 00:00:00 2001 From: marihachi Date: Sun, 23 May 2021 16:42:27 +0900 Subject: [PATCH] add FetchLike (#19) --- src/api.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/api.ts b/src/api.ts index e59ff1710..1e622d372 100644 --- a/src/api.ts +++ b/src/api.ts @@ -14,10 +14,20 @@ export function isAPIError(reason: any): reason is APIError { return reason[MK_API_ERROR] === true; } +export type FetchLike = (input: string, init?: { + method?: string; + body?: string; + credentials?: RequestCredentials; + cache?: RequestCache; + }) => Promise<{ + status: number; + json(): Promise; + }>; + export class APIClient { public origin: string; public credential: string | null | undefined; - public fetch: (typeof fetch); + public fetch: FetchLike; constructor(opts: { origin: APIClient['origin'];