const REQUEST_URI_TEST = "https://test.huheyoudi.net/douyou/rest";
const REQUEST_URI = "https://www.huheyoudi.net/douyou/rest";
var uri = REQUEST_URI + "/logon/15850760706?current_logon_device=MI4&password=qwer1234";
fetch(uri, {
method: "GET",
headers: {
Accept: "application/json",
"Content-Type": "application/json"
}
})
.then(response => {
console.log(response);
return response.json();
})
.then(json => {
console.log(json);
})
.catch(error => {
console.log(error);
});
使用REQUEST_URI_TEST将导致异常。而且我无法在捕获区域捕获任何错误,我可以通过react native工具iin chrome查看日志。
TypeError: Network request failed
at XMLHttpRequest.xhr.onerror (E:\WorkSpace\01.ReactNative\DouYouRN\node_modules\whatwg-fetch\fetch.js:441)
at XMLHttpRequest.dispatchEvent (E:\WorkSpace\01.ReactNative\DouYouRN\node_modules\event-target-shim\lib\event-target.js:172)
at XMLHttpRequest.setReadyState (E:\WorkSpace\01.ReactNative\DouYouRN\node_modules\react-native\Libraries\Network\XMLHttpRequest.js:567)
at XMLHttpRequest.__didCompleteResponse (E:\WorkSpace\01.ReactNative\DouYouRN\node_modules\react-native\Libraries\Network\XMLHttpRequest.js:397)
at E:\WorkSpace\01.ReactNative\DouYouRN\node_modules\react-native\Libraries\Network\XMLHttpRequest.js:503
at RCTDeviceEventEmitter.emit (E:\WorkSpace\01.ReactNative\DouYouRN\node_modules\react-native\Libraries\vendor\emitter\EventEmitter.js:179)
at MessageQueue.__callFunction (E:\WorkSpace\01.ReactNative\DouYouRN\node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:351)
at E:\WorkSpace\01.ReactNative\DouYouRN\node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:116
at MessageQueue.__guardSafe (E:\WorkSpace\01.ReactNative\DouYouRN\node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:314)
at MessageQueue.callFunctionReturnFlushedQueue (E:\WorkSpace\01.ReactNative\DouYouRN\node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:115)
但是REQUEST_URI可以正确登录!
我不知道原因,邮递员可以访问两个URI。有人可以给我一些建议吗?