Skip to content

Commit

Permalink
feat: Use import() for node-fetch to allow cjs usage
Browse files Browse the repository at this point in the history
  • Loading branch information
sebbo2002 committed Mar 31, 2023
1 parent a008c10 commit 5f768c0
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/tools.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { RequestFetchOptions, RequestFetchResponse, RequestOptions } from './types.js';
import fetch from 'node-fetch';

export async function request<T> (
url: string,
Expand Down Expand Up @@ -27,7 +26,7 @@ export async function request<T> (

let response: RequestFetchResponse | null = null;
for (let i = 0; i < 10; i++) {
response = await (options.fetch || fetch)(url, init);
response = await (options.fetch || (await import('node-fetch')).default)(url, init);
if(response.ok) {
break;
}
Expand Down

0 comments on commit 5f768c0

Please sign in to comment.