Import and use whatwg-fetch
mainYou can automatically polyfill window.fetch by importing the package. If you need to access the polyfill implementation specifically (e.g., to use abort functionality in browsers with outdated native fetch), you can import it as a named export.
// Automatically polyfills window.fetch
import 'whatwg-fetch';
// Access the polyfill implementation directly
import {fetch as fetchPolyfill} from 'whatwg-fetch';
window.fetch(...); // uses native browser version if available
fetchPolyfill(...); // uses polyfill implementation