title: React Native unable to run a successful fetch to express API
body: <p>Given the following setup:    </p>
  
  <p><strong>server.js</strong></p>
  
  <pre><code>const express = require('express')
  const path = require('path')
  const app = express()
  const cors = require('cors')
  const port = process.env.PORT || 8080
  
  app.use(cors())
  
  app.get('/api', (req, res) =&gt; {
    res.send({code: 200, message: 'I have arrived!'})
  })
  
  app.listen(port, () =&gt; console.log(`I can hear your thoughts on ${port}`))
  </code></pre>
  
  <p>and the presentational component with call:</p>
  
  <p><strong>App.js</strong></p>
  
  <pre><code>componentDidMount() {
    fetch(`/api`, {
      method: 'GET',
      headers: {
        'Content-Type': 'application/json',
        'Accept': 'application/json'
      }
    }).then(res =&gt; {
      console.log(res)
      return res.json()
    }).then(response =&gt; {
      console.log(response)
      this.data = response
    }).catch(error =&gt; {
      this.error = error.message || error.error
    })
  }
  </code></pre>
  
  <p><strong>package.json:</strong></p>
  
  <pre><code>"scripts": {
    "start": "npm-run-all --parallel start:client start:server",
    "start:client": "node node_modules/react-native/local-cli/cli.js start",
    "start:server": "node server.js",
    "test": "jest"
  },
  </code></pre>
  
  <p>I am running the app via <code>yarn start</code>, and I see the log: "I can hear your thoughts"...  <strong>The fetch call, however, is never made</strong>.  If I supply another fully qualified url within the fetch call it returns the data as expected, however I am unable to hit the express api from within the component.</p>
  
  <ul>
  <li>If I place <code>http://localhost:8080/api</code> in the browser I get the response.</li>
  <li>If I place <code>http://localhost:8080/api</code> in the fetch call it is never called (or at least doesn't appear to be).</li>
  </ul>
  
  <p><strong>How can I properly configure this to call the express api when running locally?</strong></p>
  
  <p>As always any and all direction is appreciated, so thanks in advance!</p>