title: React Native Android Fetch failing on connection to local API
body: <p>I'm using the fetch API in my react-native Android app to make requests to a local API. I usually query said API from react web apps at http://localhost:8163.</p>
  <p>I'm testing my app on my physical device in debugger mode. I read somewhere that react-native can't query localhost the same way a web app can. Apparently you have to use <code>http://10.0.2.2:[PORT_NUMBER_HERE]/</code> which is an alias for `http://127.0.0.1:[PORT_NUMBER_HERE] according to the Android emulator docks. I'm not sure if this is what I'm supposed to be doing for testing on a physical device.</p>
  <p>My fetch code looks like the following:</p>
  <pre><code>fetchToken() {
      fetch('http://10.0.2.2:8163/extension/auth', {
          method: 'GET',
          headers: {
              'Accept': 'application/json',
              'Content-type': 'application/json'
          }
      })
      .then((response)) =&gt; console.log('successful fetchToken response: ', response.json()))
      .catch((error) =&gt; console.log('fetchToken error: ', error))
      .done();
  }
  </code></pre>
  <p>The request always hangs for a while and then reaches the <code>catch</code> block with the unhelpful error <code>TypeError: Network request failed(...)</code>. Checking the logs for my local API, they don't register the request at all.</p>
  <p>So I have no idea if I'm querying my local API correctly to get the resource that I want, and if I am, I don't know why the fetch is failing.</p>