简体   繁体   English

反应本地网络请求失败

[英]React Native network request failed

How to skip ssl verification? 如何跳过SSL验证?

fetch('url',{ methhod: 'GET', header:{Accept:'application/json',}})
.then(res=>console.log(res))

错误日志

I sloved the problem with installing rn-fetch-blob library and bypass ssl certificate 我解决了安装rn-fetch-blob库并绕过SSL证书的问题

   RNFetchBlob.config({ trusty: true })
  .fetch(
    'POST',
    'https://yourAPI',
    {
      'Content-Type': 'application/json',
    },
    dataObj
  )
  .then(res => console.log(res));

If you trying to make a GET request there is no need to pass the method and header info. 如果您尝试发出GET请求,则无需传递方法和标头信息。

let apiUrl = "https://url/"
fetch(apiUrl)
 .then((response) => response.json())
 .then((jsonData=>{
   console.log(jsonData);
})
.catch((err)=>{
  console.log("err",err);
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM