diff --git a/src/client.js b/src/client.js index 8b26b0f..e8e9bd2 100644 --- a/src/client.js +++ b/src/client.js @@ -1,11 +1,12 @@ let isNode = false; -if (typeof window === 'undefined' || typeof globalThis.fetch !== 'undefined') { - globalThis.fetch = (await import('node-fetch')).default; - isNode = true; -} +/** + * Initialize fetch + * @return {Promise} + */ async function initializeFetch() { - if (typeof globalThis.fetch === 'undefined') { + if (typeof window === 'undefined' || + typeof globalThis.fetch === 'undefined') { const nodeFetch = await import('node-fetch'); fetch = nodeFetch.default; isNode = true;