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:
@@ -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())
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user