Files
zkldi_Tachi/server/src/utils/fetch.ts
T

15 lines
445 B
TypeScript

import { Environment } from "lib/setup/config";
import nodeFetch from "node-fetch";
import type { RequestInfo, RequestInit, Response } from "node-fetch";
const fetch =
Environment.nodeEnv === "test"
? () => {
throw new Error("Cannot use real fetch inside testing env!");
}
: nodeFetch;
export type NodeFetch = (url: RequestInfo, init?: RequestInit | undefined) => Promise<Response>;
export default fetch as unknown as NodeFetch;