React native axios或fetch向任何HTTP调用提供网络错误
我在打一个简单的电话到我的开发甚至生产应用程序时遇到了问题。环境是:React native axios或fetch向任何HTTP调用提供网络错误,react-native,React Native,我在打一个简单的电话到我的开发甚至生产应用程序时遇到了问题。环境是: "axios": "^0.19.0", "react": "16.8.6", "react-native": "0.60.5" API的构建包括: Django 1.11 and DRF 我试过的AVD是Android9API28,Android8API27 我的开发机器运行在甚至(使用runsslserver)上,并且生产中的应用程序是相同的 对于axios,我这样称呼它: axios .post(APIS.STA
"axios": "^0.19.0",
"react": "16.8.6",
"react-native": "0.60.5"
API的构建包括:
Django 1.11 and DRF
我试过的AVD是Android9API28,Android8API27
我的开发机器运行在甚至(使用runsslserver)上,并且生产中的应用程序是相同的
对于axios,我这样称呼它:
axios
.post(APIS.START.LOGIN, {loginData})
.then(res => {
console.log(res);
console.log(res.data);
})
.catch(err => {
console.log(err);
})
.finally(console.log('done'));
fetch和axios的错误与此类似:网络故障。axios的控制台日志为:
done
D:\dev\go\mobile_apps\agronomo\screens\guest\ScreenLogin.js:69 Error: Network Error
at createError (D:\dev\go\mobile_apps\agronomo\node_modules\axios\lib\core\createError.js:16)
at XMLHttpRequest.handleError (D:\dev\go\mobile_apps\agronomo\node_modules\axios\lib\adapters\xhr.js:81)
at XMLHttpRequest.dispatchEvent (D:\dev\go\mobile_apps\agronomo\node_modules\event-target-shim\dist\event-target-shim.js:818)
at XMLHttpRequest.setReadyState (D:\dev\go\mobile_apps\agronomo\node_modules\react-native\Libraries\Network\XMLHttpRequest.js:574)
at XMLHttpRequest.__didCompleteResponse (D:\dev\go\mobile_apps\agronomo\node_modules\react-native\Libraries\Network\XMLHttpRequest.js:388)
at D:\dev\go\mobile_apps\agronomo\node_modules\react-native\Libraries\Network\XMLHttpRequest.js:501
at RCTDeviceEventEmitter.emit (D:\dev\go\mobile_apps\agronomo\node_modules\react-native\Libraries\vendor\emitter\EventEmitter.js:189)
at MessageQueue.__callFunction (D:\dev\go\mobile_apps\agronomo\node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:395)
at D:\dev\go\mobile_apps\agronomo\node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:106
at MessageQueue.__guard (D:\dev\go\mobile_apps\agronomo\node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:343)
D:\dev\go\mobile_apps\agronomo\node_modules\react-native\Libraries\YellowBox\YellowBox.js:71 Possible Unhandled Promise Rejection (id: 1):
TypeError: f is not a function
TypeError: f is not a function
at blob:file:///bdfd99d2-9789-4422-9c3b-ab0962405db9:42178:30
at tryCallOne (blob:file:///bdfd99d2-9789-4422-9c3b-ab0962405db9:45399:14)
at blob:file:///bdfd99d2-9789-4422-9c3b-ab0962405db9:45500:17
at blob:file:///bdfd99d2-9789-4422-9c3b-ab0962405db9:45801:21
at _callTimer (blob:file:///bdfd99d2-9789-4422-9c3b-ab0962405db9:45690:9)
at _callImmediatesPass (blob:file:///bdfd99d2-9789-4422-9c3b-ab0962405db9:45726:9)
at Object.callImmediates (blob:file:///bdfd99d2-9789-4422-9c3b-ab0962405db9:45945:14)
at MessageQueue.__callImmediates (blob:file:///bdfd99d2-9789-4422-9c3b-ab0962405db9:15222:16)
at blob:file:///bdfd99d2-9789-4422-9c3b-ab0962405db9:15028:18
at MessageQueue.__guard (blob:file:///bdfd99d2-9789-4422-9c3b-ab0962405db9:15205:13)
console.warn @ D:\dev\go\mobile_apps\agronomo\node_modules\react-native\Libraries\YellowBox\YellowBox.js:71
onUnhandled @ D:\dev\go\mobile_apps\agronomo\node_modules\react-native\Libraries\Promise.js:37
onUnhandled @ D:\dev\go\mobile_apps\agronomo\node_modules\promise\setimmediate\rejection-tracking.js:71
(anonymous) @ D:\dev\go\mobile_apps\agronomo\node_modules\react-native\Libraries\Core\Timers\JSTimers.js:250
_callTimer @ D:\dev\go\mobile_apps\agronomo\node_modules\react-native\Libraries\Core\Timers\JSTimers.js:146
callTimers @ D:\dev\go\mobile_apps\agronomo\node_modules\react-native\Libraries\Core\Timers\JSTimers.js:399
__callFunction @ D:\dev\go\mobile_apps\agronomo\node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:395
(anonymous) @ D:\dev\go\mobile_apps\agronomo\node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:106
__guard @ D:\dev\go\mobile_apps\agronomo\node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:343
callFunctionReturnFlushedQueue @ D:\dev\go\mobile_apps\agronomo\node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:105
e @ RNDebuggerWorker.js:1
它在生产中起作用,但在您的机器中不起作用?您是否检查过SSL加密是否存在问题?嘿@AndréPinto它在生产或本地主机上不起作用。生产证书具有正确的SSL证书,而开发证书是自签名证书。