2
0
mirror of https://github.com/tenrok/axios.git synced 2026-06-14 18:42:33 +03:00

fix(fetch): enhance fetch API detection; (#6413)

This commit is contained in:
Dmitriy Mozgovoy
2024-05-21 17:20:15 +03:00
committed by GitHub
parent 67d1373131
commit 4f79aef81b
+3 -3
View File
@@ -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())
);