React native 获取网络请求失败

React native 获取网络请求失败,react-native,expo,React Native,Expo,我正在运行expo v33的react native。我需要使用fetch以json格式从web服务器获取数据 打电话的时候 fetch('https://elpuente.io', { method: "GET", }) .then((response) => console.log(response)) .catch((error) => { console.error(error);

我正在运行expo v33的react native。我需要使用fetch以json格式从web服务器获取数据

打电话的时候

fetch('https://elpuente.io', {
        method: "GET",
      })        
      .then((response) => console.log(response))
      .catch((error) => {
        console.error(error);
      });
我得到这个警告:

Network request failed

Stack trace:
  node_modules/react-native/Libraries/vendor/core/whatwg-fetch.js:504:29 in onerror
  node_modules/event-target-shim/lib/event-target.js:172:43 in dispatchEvent
  node_modules/react-native/Libraries/Network/XMLHttpRequest.js:580:29 in setReadyState
  node_modules/react-native/Libraries/Network/XMLHttpRequest.js:394:25 in __didCompleteResponse
  node_modules/react-native/Libraries/vendor/emitter/EventEmitter.js:190:12 in emit
  node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:366:47 in __callFunction
  node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:106:26 in <unknown>
  node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:314:10 in __guard
  node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:105:17 in callFunctionReturnFlushedQueue
  ...
网络请求失败
堆栈跟踪:
onerror中的node_modules/react native/Libraries/vendor/core/whatwg fetch.js:504:29
dispatchEvent中的node_modules/event target shim/lib/event target.js:172:43
setReadyState中的node_modules/react native/Libraries/Network/XMLHttpRequest.js:580:29
node_modules/react native/Libraries/Network/XMLHttpRequest.js:394:25 in_uuudidcompleteresponse
emit中的node_modules/react native/Libraries/vendor/emitter/EventEmitter.js:190:12
调用函数中的node_modules/react native/Libraries/BatchedBridge/MessageQueue.js:366:47
node_modules/react native/Libraries/BatchedBridge/MessageQueue.js:106:26 in
保护中的node_modules/react native/Libraries/BatchedBridge/MessageQueue.js:314:10
callFunctionReturnFlushedQueue中的node_modules/react native/Libraries/BatchedBridge/MessageQueue.js:105:17
...
使用localhost时,一切正常。我也尝试使用ip地址获取,但得到了相同的警告


谢谢。

可以在服务器上禁用重定向到https并使用http

问题在于找不到证书路径的信任锚点。嗨,Oleg,谢谢。你知道怎么解决这个问题吗?应该在服务器端或应用程序端修复?您是否在expo单机版应用程序中进行了测试?是的,在单机版和发布版模式下,出现了相同的错误。我试过使用http和https,但还是出现了同样的错误。谢谢你的回答。我修好了!ssl链出现问题。我已经在apache中更新了virtualhost的SSLCertificateChainFile,现在我正在从远程服务器获取数据。