Skip to content

Commit

Permalink
a workaround for node-fetch using esm
Browse files Browse the repository at this point in the history
  • Loading branch information
xsro committed Dec 5, 2021
1 parent 05e6de2 commit 28ed233
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/utils/downloadFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* API for downloading information from web
*/
import { logger } from "./logger";
import fetch from "node-fetch";
import { fetch } from "./fetch";

export async function downloadFromMultiSources(urls: string[]): Promise<string | undefined> {
for (const url of urls) {
Expand Down
7 changes: 7 additions & 0 deletions src/utils/fetch.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
// @ts-check

export const fetch =
process.platform
? eval("(...args) => import('node-fetch').then(({default: fetch}) => fetch(...args))")
: window.fetch;

0 comments on commit 28ed233

Please sign in to comment.