DEV Community

Discussion on: How to polyfill JavaScript fetch function for Internet Explorer

hispanic profile image
Michael Harry Scepaniak

Thanks for posting. I found this helpful. However, instead of testing for IE, it seems more robust to mimic/duplicate the test that the fetch polyfill, itself, performs, like so:

var testGlobal =
    (typeof globalThis !== 'undefined' && globalThis) ||
    (typeof self !== 'undefined' && self) ||
    (typeof global !== 'undefined' && global)

if (!testGlobal.fetch) {
Enter fullscreen mode Exit fullscreen mode