When I use the JavaScript FETCH API to access an HTTP resource, I get an error:

The Network Request Failed.

I googled and found other people on StackOverflow with similar issues:

Stackoverflow.com/questions/3…

IOS doesn’t allow HTTP requests by default, only HTTPS. If you want to use HTTP, add the following information to info.plist:


<key>NSAppTransportSecurity</key>

<dict>

  <key>NSAllowsArbitraryLoads</key>

  <true/>

</dict>

<key>NSAppTransportSecurity</key>

<dict>

 <key>NSExceptionDomains</key>

 <dict>

  <key>yourserver.com</key>

  <dict>

   <! --Include to allow subdomains-->

   <key>NSIncludesSubdomains</key>

   <true/>

   <! --Include to allow HTTP requests-->

   <key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>

   <true/>

   <! --Include to specify minimum TLS version-->

   <key>NSTemporaryExceptionMinimumTLSVersion</key>

   <string>TLSv1.1</string>

  </dict>

 </dict>

</dict>
Copy the code

React Native for more information:

Facebook. Making. IO/react – nativ…

For more of Jerry’s original articles, please follow the public account “Wang Zixi “: