Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
February 16, 2022 10:00 am GMT

Setting up for connect fetching local API or http React Native IOS / MacOS

Some of you maybe got confused, why the API doesnt work and get error when try to connect to local API or maybe http instead https.

It because by default React Native cannot connect to API with http request, it's should be https

To solve this problem, you need a bit setup on plist file

first go to folder
ios > {your file name} > info.plist

for example
ios > FashionApp > info.plist

after that you copy this file

<key>NSAppTransportSecurity</key><dict>     <key>NSExceptionDomains</key>     <dict>         <key>NSExceptionAllowsInsecureHTTPLoads</key>         <true/>     <key>localhost</key>     <dict>         <key>NSExceptionAllowsInsecureHTTPLoads</key>         <true/>     </dict>     </dict>     <key>NSAllowsArbitraryLoads</key>     <true/></dict>

Block this section on plist file, and delete it. After that, you paste from your copying before

Image description

Success, now you can connect with http or local host without get any errors.
If you have any question, feel free to ask me on
email : [email protected]
instagram : charismaaji


Original Link: https://dev.to/charismaaji/setting-up-for-connect-fetching-local-api-or-http-react-native-ios-macos-2pd8

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To