import * as denoShim from "deno.ns"; export type Reviver = Parameters[1]; export const jsonFetch = async ( url: RequestInfo | URL, init?: RequestInit, options?: { parseJson: Reviver }, ): Promise => { const res = await denoShim.fetch(url.toString(), init); if (!res.ok) { throw Error(res.statusText); } const text = await res.text(); const parsed = JSON.parse(text, options?.parseJson); if ("status" in parsed && parsed.status !== 0) { throw Error(parsed); } return parsed; };