I\'d like to view my network requests in React Native to help me debug - ideally in the \'Network\' tab of Chrome\'s devtools.
There are some closed issues about thi
This is what I've been using in the entry point of my app
const _XHR = GLOBAL.originalXMLHttpRequest ?
GLOBAL.originalXMLHttpRequest :
GLOBAL.XMLHttpRequest
XMLHttpRequest = _XHR
EDIT: frevib linked to more concise syntax below. Thanks frevib!
GLOBAL.XMLHttpRequest = GLOBAL.originalXMLHttpRequest || GLOBAL.XMLHttpRequest;
Explanation:
GLOBAL.originalXMLHttpRequest refers the Chrome Dev Tools copy of XHR. It is provided by RN as an escape hatch. Shvetusya's solution will only work if the dev tools are open and thus providing XMLHttpRequest.
EDIT: You will need to allow cross origin requests when in debugger mode. With chrome you can use this handy plugin.
EDIT: Read about the RN github issue that lead me to this solution