![](/img/trans.png)
[英]Network request failed when trying POST request in React-Native
[英]React-native fetch fails with “Network request failed” when trying to hit remote server
我在 AWS EC2 上运行后端服务器,当我尝试使用 fetch 发出请求时,它只是说网络请求失败。 今晚我尝试了十亿件事,我什至买了一个域并设置了 ssl 因为这里的其他问题表明这是问题所在,但这并没有奏效。 Fetch 在本地工作得很好,但指向我在 AWS 上的服务器却不行。 如果我记录 URL 我将在我的浏览器中获取并粘贴它,它应该可以正常工作。
Network request failed
- node_modules\whatwg-fetch\dist\fetch.umd.js:474:29 in xhr.onerror
- node_modules\event-target-shim\dist\event-target-shim.js:818:39 in EventTarget.prototype.dispatchEvent
- node_modules\react-native\Libraries\Network\XMLHttpRequest.js:574:29 in setReadyState
- node_modules\react-native\Libraries\Network\XMLHttpRequest.js:388:25 in __didCompleteResponse
- node_modules\react-native\Libraries\vendor\emitter\EventEmitter.js:190:12 in emit
- node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:436:47 in __callFunction
- node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:111:26 in __guard$argument_0
- node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:384:10 in __guard
- node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:110:17 in __guard$argument_0
* [native code]:null in callFunctionReturnFlushedQueue
fetch.umd.js:474:29 中的错误是: Event { "isTrusted": false, }
我希望这对你有帮助,把它放在你的清单文件中的应用程序标签下
<application
....
android:usesCleartextTraffic="true"
/>
我的问题是 SSL 相关的。 只是没有使用 nginx 正确设置
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.