Title: Making HTTP requests isn’t working in React Native iOS
Tags: javascript;ios;react-native;http
Question: I am working on a group project where we have created a React Native app. Two of my team members worked on the server-side of the project and I am working on the client-side, the app works perfectly on Android but the http requests aren't working in iOS. I tried searching for solutions, most of them said that I need to add a few lines to the info.plist file, I tried all that but none of that worked so hopefully no one will mark this question as a duplicate. 

I am stuck in the Login page of the app, here is the code: 
UserLogin.js

```// This function is called when the login button is pressed
submit=() =&gt; {
// Some validations

if(Object.keys(this.state.success).length==0){
  const URL="http://574-265-6100:4000/userLogin"
  const loginconfirm = async () =&gt; {
    try {
      return await axios.post(URL,this.state)
      } catch (error) {
        console.error(error)
      }
    }
    const getloginconfirm = async () =&gt; {
    const confirm = await loginconfirm()

     if (confirm.data.message=="success") {
        alert("Successfully logged in")
        UserInfo.setName(confirm.data.name);
        UserInfo.setId(confirm.data.id);  
        if(confirm.data.category=="Exporter"){
          const {navigation} = this.props;
          navigation.navigate('ScreenMove')
          //Should go to ScreenMove.js
        }else{
          const {navigation} = this.props;
          navigation.navigate('FarmerHomePage')
        }
       }
    else{alert("The username does not exist or password does not match the username")}
     }
    getloginconfirm();
}
```

Here's my info.plist

```<?xml version="1.0" encoding="UTF-8"?&gt;
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"&gt;
<plist version="1.0"&gt;
<dict&gt;
    <key&gt;CFBundleDevelopmentRegion</key&gt;
    <string&gt;en</string&gt;
    <key&gt;CFBundleDisplayName</key&gt;
    <string&gt;UNAGI</string&gt;
    <key&gt;CFBundleExecutable</key&gt;
    <string&gt;$(EXECUTABLE_NAME)</string&gt;
    <key&gt;CFBundleIdentifier</key&gt;
    <string&gt;$(PRODUCT_BUNDLE_IDENTIFIER)</string&gt;
    <key&gt;CFBundleInfoDictionaryVersion</key&gt;
    <string&gt;6.0</string&gt;
    <key&gt;CFBundleName</key&gt;
    <string&gt;$(PRODUCT_NAME)</string&gt;
    <key&gt;CFBundlePackageType</key&gt;
    <string&gt;APPL</string&gt;
    <key&gt;CFBundleShortVersionString</key&gt;
    <string&gt;1.0</string&gt;
    <key&gt;CFBundleSignature</key&gt;
    <string&gt;????</string&gt;
    <key&gt;CFBundleURLTypes</key&gt;
    <array&gt;
        <dict/&gt;
    </array&gt;
    <key&gt;CFBundleVersion</key&gt;
    <string&gt;1</string&gt;
    <key&gt;LSRequiresIPhoneOS</key&gt;
    <true/&gt;
    <key&gt;NSAppTransportSecurity</key&gt;
    <dict&gt;
        <key&gt;NSAllowsArbitraryLoads</key&gt;
        <true/&gt;
        <key&gt;NSExceptionDomains</key&gt;
        <dict&gt;
            <key&gt;localhost</key&gt;
            <dict&gt;
                <key&gt;NSIncludesSubdomains</key&gt;
                <false/&gt;
                <key&gt;NSExceptionAllowsInsecureHTTPLoads</key&gt;
                <true/&gt;
            </dict&gt;
        </dict&gt;
    </dict&gt;
    <key&gt;NSLocationWhenInUseUsageDescription</key&gt;
    <string&gt;</string&gt;
    <key&gt;UILaunchStoryboardName</key&gt;
    <string&gt;LaunchScreen</string&gt;
    <key&gt;UIRequiredDeviceCapabilities</key&gt;
    <array&gt;
        <string&gt;armv7</string&gt;
    </array&gt;
    <key&gt;UISupportedInterfaceOrientations</key&gt;
    <array&gt;
        <string&gt;UIInterfaceOrientationPortrait</string&gt;
        <string&gt;UIInterfaceOrientationLandscapeLeft</string&gt;
        <string&gt;UIInterfaceOrientationLandscapeRight</string&gt;
    </array&gt;
    <key&gt;UIViewControllerBasedStatusBarAppearance</key&gt;
    <false/&gt;
</dict&gt;
</plist&gt;
```

Here's the error I'm getting:

```
  2020-04-29 20:02:04.589406+0530 UNAGI[30263:604617] []
  nw_socket_handle_socket_event [C8:2] Socket SO_ERROR [60: Operation
  timed out] 2020-04-29 20:02:04.590542+0530 UNAGI[30263:604617]
  Connection 8: received failure notification 2020-04-29
  20:02:04.592849+0530 UNAGI[30263:604617] Connection 8: failed to
  connect 1:60, reason -1 2020-04-29 20:02:04.594920+0530
  UNAGI[30263:604617] Connection 8: encountered error(1:60) 2020-04-29
  20:02:04.605649+0530 UNAGI[30263:604617] Task
  <695EDB52-BC43-4A20-93D2-A3481D44468C>.<3> HTTP load failed, 0/0 bytes
  (error code: -1001 [1:60]) 2020-04-29 20:02:04.622585+0530
  UNAGI[30263:604513] Task <695EDB52-BC43-4A20-93D2-A3481D44468C>.<3>
  finished with error [-1001] Error Domain=NSURLErrorDomain Code=-1001
  "The request timed out." UserInfo={_kCFStreamErrorCodeKey=60,
  NSUnderlyingError=0x60000235c360 {Error Domain=kCFErrorDomainCFNetwork
  Code=-1001 "(null)" UserInfo={_kCFStreamErrorCodeKey=60,
  _kCFStreamErrorDomainKey=1}}, _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <695EDB52-BC43-4A20-93D2-A3481D44468C>.<3>,
  _NSURLErrorRelatedURLSessionTaskErrorKey=(
      "LocalDataTask <695EDB52-BC43-4A20-93D2-A3481D44468C>.<3>" ), NSLocalizedDescription=The request timed out.,
  NSErrorFailingURLStringKey=http://574-265-6100:4000/userLogin,
  NSErrorFailingURLKey=http://574-265-6100:4000/userLogin,
  _kCFStreamErrorDomainKey=1} 2020-04-29 20:02:04.639 [error][tid:com.facebook.react.JavaScript] Error: timeout of 0ms
  exceeded 2020-04-29 20:02:04.761
  [warn][tid:com.facebook.react.JavaScript] Possible Unhandled Promise
  Rejection (id: 0): TypeError: undefined is not an object (evaluating
  'confirm.data')
  getloginconfirm$@http://localhost:8081/index.bundle?platform=ios&amp;dev=true&amp;minify=false:132789:32
  tryCatch@http://localhost:8081/index.bundle?platform=ios&amp;dev=true&amp;minify=false:30544:23
  invoke@http://localhost:8081/index.bundle?platform=ios&amp;dev=true&amp;minify=false:30720:32
  tryCatch@http://localhost:8081/index.bundle?platform=ios&amp;dev=true&amp;minify=false:30544:23
  invoke@http://localhost:8081/index.bundle?platform=ios&amp;dev=true&amp;minify=false:30620:30
  http://localhost:8081/index.bundle?platform=ios&amp;dev=true&amp;minify=false:30630:21
  tryCallOne@http://localhost:8081/index.bundle?platform=ios&amp;dev=true&amp;minify=false:3344:16
  http://localhost:8081/index.bundle?platform=ios&amp;dev=true&amp;minify=false:3445:27
  _callTimer@http://localhost:8081/index.bundle?platform=ios&amp;dev=true&amp;minify=false:32458:17
  _callImmediatesPass@http://localhost:8081/index.bundle?platform=ios&amp;dev=true&amp;minify=false:32494:19
  callImmediates@http://localhost:8081/index.bundle?platform=ios&amp;dev=true&amp;minify=false:32712:33
  callImmediates@[native code]
  __callImmediates@http://localhost:8081/index.bundle?platform=ios&amp;dev=true&amp;minify=false:2752:35
  http://localhost:8081/index.bundle?platform=ios&amp;dev=true&amp;minify=false:2538:34
  __guard@http://localhost:8081/index.bundle?platform=ios&amp;dev=true&amp;minify=false:2735:15
  flushedQueue@http://localhost:8081/index.bundle?platform=ios&amp;dev=true&amp;minify=false:2537:21
  flushedQueue@[native code] callFunctionReturnFlushedQueue@[native
  code]
```

Appreciate the feedback! :)

Comment: @BaderSerhan I didn’t find any solution for this :/

Comment: Are you still having this issue? Or how did you manage to solve it?

Comment: Thank you for your reply, I appreciate it.



{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 0, 'CommentCount': 3, 'ContentLicense': 'CC BY-SA 4.0', 'CreationDate': '2020:00:04/29/20', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<javascript><ios><react-native><http>', 'Title': 'Making HTTP requests isn’t working in React Native iOS', 'ViewCount': 687, 'id': 61505009, 'user_AboutMe': '', 'user_AccountId': 16165519.0, 'user_DisplayName': 'Abdullah Ajmal', 'user_Reputation': 407.0, 'user_Views': 121.0, 'user_id': 11670593.0}}