Skip to main content
Module

x/polkadot/x-fetch/node.ts

Package publishing for deno.land/x/polkadot
Go to Latest
File

import { extractGlobal } from 'https://deno.land/x/polkadot@0.2.40/x-global/mod.ts';
export { packageInfo } from './packageInfo.ts';
const importFetch = import('https://esm.sh/node-fetch@3.3.1').catch(() => null);
let modFn: typeof fetch | null = null;
async function nodeFetch (...args: Parameters<typeof fetch>): Promise<Response> { if (modFn) { return modFn(...args); }
const mod = await importFetch;
if (!mod || !mod.default) { throw new Error('Unable to import node-fetch in this environment'); }
modFn = mod.default as unknown as typeof fetch;
return modFn(...args);}
export const fetch = /*#__PURE__*/ extractGlobal('fetch', nodeFetch);