diff --git a/lib/adapters/fetch.js b/lib/adapters/fetch.js index 3abd8cf2e2..1104553581 100644 --- a/lib/adapters/fetch.js +++ b/lib/adapters/fetch.js @@ -17,11 +17,11 @@ const fetchProgressDecorator = (total, fn) => { })); } -const isFetchSupported = typeof fetch !== 'undefined'; -const isReadableStreamSupported = isFetchSupported && typeof ReadableStream !== 'undefined'; +const isFetchSupported = typeof fetch === 'function' && typeof Request === 'function' && typeof Response === 'function'; +const isReadableStreamSupported = isFetchSupported && typeof ReadableStream === 'function'; // used only inside the fetch adapter -const encodeText = isFetchSupported && (typeof TextEncoder !== 'undefined' ? +const encodeText = isFetchSupported && (typeof TextEncoder === 'function' ? ((encoder) => (str) => encoder.encode(str))(new TextEncoder()) : async (str) => new Uint8Array(await new Response(str).arrayBuffer()) );