在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問(wèn)答/HTML5/ 在react-native 使用fetch發(fā)起ajax請(qǐng)求報(bào)錯(cuò)

在react-native 使用fetch發(fā)起ajax請(qǐng)求報(bào)錯(cuò)

在react-native中用fetch發(fā)起請(qǐng)求,出現(xiàn)以下報(bào)錯(cuò)信息:
TypeError: Network request failed

at XMLHttpRequest.xhr.onerror (index.bundle:8369)
at XMLHttpRequest.dispatchEvent (index.bundle:13584)
at XMLHttpRequest.setReadyState (index.bundle:13367)
at XMLHttpRequest.__didCompleteResponse (index.bundle:13221)
at index.bundle:13318
at RCTDeviceEventEmitter.emit (index.bundle:14084)
at MessageQueue.__callFunction (index.bundle:2109)
at index.bundle:1925
at MessageQueue.__guard (index.bundle:2080)
at MessageQueue.callFunctionReturnFlushedQueue (index.bundle:1924)

其中:請(qǐng)求的代碼如下:
fetch("http://route.showapi.com/341-1").then(function(response){console.log('你好')}).catch(err => console.log(err));

將這段請(qǐng)求代碼,直接在chrome瀏覽器下運(yùn)行是會(huì)輸出:你好??稍赗N上為什么就報(bào)錯(cuò)了呢?請(qǐng)求指教小弟

回答
編輯回答
心癌

iOS?如果要用http協(xié)議的話要在Info.plist加入:

<key>NSAppTransportSecurity</key>
<dict>
    <key>NSAllowsArbitraryLoads</key>
    <true/>
</dict>
2018年4月27日 07:57
編輯回答
有點(diǎn)壞

安卓那邊怎么解決的呢?,也遇到這樣的問(wèn)題了

2017年4月26日 12:16