ios – The way to allow HTTP calls on React Native Expo – Stack Overflow

0
132


I’ve a React Native mission constructed utilizing Expo. To check my API regionally I want to have the ability to make calls to it by way of HTTP. There are many assets on how to do that, however none of them describe find out how to do it for Expo.

Principally the answer with out Expo is to edit Data.plist and insert this into it (supply):

<key>NSAppTransportSecurity</key>
<dict>
    <key>NSAllowsArbitraryLoads</key>
    <true/>
</dict>

Since you’ll be able to’t edit Data.plist straight when utilizing Expo, you’ll be able to entry it in app.config.js as proven right here. Nonetheless, the solely instance I can discover on how to do that comes from the above hyperlink, and doesn’t present find out how to do it with dictionaries. The expo docs themselves do not present an instance both (see right here), so regardless of realizing the answer, I wouldn’t have any concept on find out how to implement it syntactically.

Inside app.config.js, I’ve tried

export default {
  ...
  ios: {
    infoPlist: {
      "NSAppTransportSecurity": [
        {
          "xml": "<dict><key>NSAllowsArbitraryLoads</key><true /></dict>"
        }
      ]
    }
  }
}

and have additionally tried

export default {
  ...
  ios: {
    infoPlist: {
        "NSAppTransportSecurity": {
            "NSAllowsArbitraryLoads": true
        }
    }
  }
}

Saving these and re-running expo begin, I nonetheless get the identical Community Request Failed error. Can anybody assist me format this?