1

How to access the react native ios http featch

fetch('http://10.0.2.2:53396/index.cfm/?fwreinit=1', {
        method: 'POST',
        headers: { 'Accept': 'application/json','Content-Type': 'application/json',},
        body: JSON.stringify({ public_key: "Arunkumar" ,private_key: "cfarun",})
    }).then((response) => response.json())
      .then((responseData) => {
            console.log(responseData);
        })

2 Answers2

1

You can fix this issue by 1. using https link for your endpoints 2. Update info.plist file and add 'App Transport Security Settings' -> 'Allow Arbitrary Loads' and set its value to 'YES'.

See attached

enter image description here

MattYao
  • 2,495
  • 15
  • 21
0

Answered here

By default, iOS will block any request that's not encrypted using SSL. If you need to fetch from a cleartext URL (one that begins with http) you will first need to add an App Transport Security exception.

Community
  • 1
  • 1
Moti Azu
  • 5,392
  • 1
  • 23
  • 32
  • multiple info.plist files in multiple directories in my React Native app. Any idea which folder contains the correct file to change? –  Mar 08 '17 at 10:19