An Interest In:
Web News this Week
- April 27, 2024
- April 26, 2024
- April 25, 2024
- April 24, 2024
- April 23, 2024
- April 22, 2024
- April 21, 2024
February 16, 2022 10:00 am GMT
Original Link: https://dev.to/charismaaji/setting-up-for-connect-fetching-local-api-or-http-react-native-ios-macos-2pd8
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
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:
Tweet
View Full Article
Dev To
An online community for sharing and discovering great ideas, having debates, and making friendsMore About this Source Visit Dev To