提取网络请求失败

时间:2019-09-15 12:34:04

标签: react-native expo

我在expo v33上运行本机反应。我需要使用提取功能以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
  ...

使用localhost时,一切正常。我也尝试使用ip地址进行提取,但收到相同的警告。

谢谢。

1 个答案:

答案 0 :(得分:0)

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