We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent a1420e8 commit eca55a6Copy full SHA for eca55a6
fetch-browser.js
@@ -1,9 +1,13 @@
1
// the whatwg-fetch polyfill installs the fetch() function
2
// on the global object (window or self)
3
-//
4
-// Return that as the export for use in Webpack, Browserify etc.
+var fetchWasDefined = 'fetch' in global;
+var originalGlobalFetch = global.fetch;
5
+
6
require('whatwg-fetch');
-var globalFetch = fetch;
7
-delete global.fetch;
+module.exports = fetch;
8
9
-module.exports = globalFetch;
+if (fetchWasDefined) {
10
+ global.fetch = originalGlobalFetch;
11
+} else {
12
+ delete global.fetch;
13
+}
0 commit comments