我正在开发一个使用 rest API 将其连接到数据库的应用程序,我的服务器有一个 SSL 证书,当我尝试发送请求时,从我的 react 本机应用程序显示此错误 msg 有没有办法在 android 的 react native 中禁用 SSL 验证。
如果有人知道,请提供帮助。
这个解决方案在安卓上对我有用:
安装包:npm install --save rn-fetch-blob
并将此代码粘贴到索引中.js
import RNFetchBlob from 'rn-fetch-blob';
AppRegistry.registerComponent(appName, () => App);
const Fetch = RNFetchBlob.polyfill.Fetch
// replace built-in fetch
window.fetch = new Fetch({
// enable this option so that the response data conversion handled automatically
auto : true,
// when receiving response data, the module will match its Content-Type header
// with strings in this array. If it contains any one of string in this array,
// the response body will be considered as binary data and the data will be stored
// in file system instead of in memory.
// By default, it only store response data to file system when Content-Type
// contains string `application/octet`.
binaryContentTypes : [
'image/',
'video/',
'audio/',
'foo/',
],
trusty : true
}).build()