參考 https://github.com/facebook/react-native/issues/934 三樓
真機或模擬器下 Debug JS Remotely, 會打開chrome,地址為ip:8081/debugger-ui/ 可能無法訪問,手動改成 http://localhost:8081/debugger-ui/ (可以訪問自動 忽略)
打開控制台查看Network面板
真機或模擬器reload 發現在Chrome面板下並沒有我們的fetch網絡請求
我的react-native版本是0.57.5 其他版本可以自己找找
react-native\Libraries\Core\InitializeCore.js -> 搜索 XMLHttpRequest 會有注釋提醒
The native XMLHttpRequest in Chrome dev tools is CORS aware and won't let you fetch anything from the internet
(Chrome開發工具中的原生XMLHttpRequest具有CORS感知功能,不允許您從互聯網上獲取任何內容 谷歌翻譯)
注釋掉 polyfillGlobal('XMLHttpRequest', () => require('XMLHttpRequest'));
再在真機或模擬器reload 查看Network面板,此時就可以查看到我們的fetch請求了