简体   繁体   中英

React Native network request failed

How to skip ssl verification?

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

   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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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