我有一个可以在ios设备,ios模拟器和邮递员上良好运行的api。但它无法与android设备和android模拟器一起使用。
这是我的api https://cloud.vegasegamingclub.com/proxy/neon/checkpin
发布方法
这就是我在应用中执行的操作
async componentDidMount() {
try {
let res = await fetch('https://cloud.vegasegamingclub.com/proxy/neon/checkpin', {
method: 'post',
})
console.log('res', res)
} catch (error) {
console.log('error', error)
}
}
这段代码在ios和post man上运行良好,但在android上失败,我收到了此错误
Network request failed
- 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:578:29 in setReadyState
- node_modules/react-native/Libraries/Network/XMLHttpRequest.js:392:25 in __didCompleteResponse
- node_modules/react-native/Libraries/vendor/emitter/EventEmitter.js:191:12 in emit
- node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:349:47 in __callFunction
- node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:106:26 in <unknown>
- node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:297:10 in __guard
- node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:105:17 in callFunctionReturnFlushedQueue
* [native code]:null in callFunctionReturnFlushedQueue
我也尝试过替换fetch axios,同样的错误。
答案 0 :(得分:0)
答案是获取API的某些ssl出现了问题。选项1要求开发人员更改证书类型。