Skip to content

Instantly share code, notes, and snippets.

@peterpme
Last active August 28, 2015 00:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save peterpme/6a7055fcb46281e51199 to your computer and use it in GitHub Desktop.
Save peterpme/6a7055fcb46281e51199 to your computer and use it in GitHub Desktop.
Expose your React Native network requests in Chrome
103 function setUpXHR() {
104 // The native XMLHttpRequest in Chrome dev tools is CORS aware and won't
105 // let you fetch anything from the internet
106 GLOBAL.XMLHttpRequest = require('XMLHttpRequest'); // COMMENT OUT
107 GLOBAL.FormData = require('FormData'); // COMMENT OUT
108
109 var fetchPolyfill = require('fetch'); // COMMENT OUT
110 GLOBAL.fetch = fetchPolyfill.fetch; // COMMENT OUT
111 GLOBAL.Headers = fetchPolyfill.Headers; // COMMENT OUT
112 GLOBAL.Request = fetchPolyfill.Request; // COMMENT OUT
113 GLOBAL.Response = fetchPolyfill.Response; // COMMENT OUT
114 }
@peterpme
Copy link
Author

Take care to revert this once you're ready for production

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment