Vaqif
Vaqif

Reputation: 635

React Native network request failed

How to skip ssl verification?

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

error log

Upvotes: 0

Views: 791

Answers (2)

Mohammed Ashfaq
Mohammed Ashfaq

Reputation: 3426

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);
}

Upvotes: 0

Vaqif
Vaqif

Reputation: 635

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));

Upvotes: 1

Related Questions