title: Error Fetching Data in React Native with Laravel as a Back-End
body: <p>I am using laravel as my back-end and I've tested all the method and it works tho. I already test it using postman for my laravel as a backend and it works. But when I try it in react native it didnt work at all. I'm still new to react native. </p>
  
  <p><strong>Here's my code for PinjamList.js in RN:</strong></p>
  
  <pre><code>import React, {Component} from 'react';
  import {View, Text, StyleSheet} from 'react-native';
  import PropTypes from 'prop-types';
  
  export default class PinjamList extends Component {
  
      static propTypes = {
          pinjams: PropTypes.array.isRequired
      };
  
      render() {
          return ({
              this.props.pinjams.map((pinjam) =&gt; {
                  return ({pinjam.ketua_kegiatan} | {pinjam.lab})
              })
          });
      }
  }
  
  const styles = StyleSheet.create({
      pinjamList: {
          flex: 1,
          flexDirection: 'column',
          justifyContent: 'space-around',
      },
      pinjamtext: {
          fontSize: 24,
          fontWeight: 'bold',
          textAlign: 'center',
      }
  });
  
  </code></pre>
  
  <p><strong>And this one is js file for fetching the data:</strong></p>
  
  <pre><code>const URI = 'http://localhost:8000';
  export default {
      async fetchDataPinjam() {
          try {
              let response = await fetch(URI + '/api/pinjams');
              let responseJsonData = await response.json();
              return
              responseJsonData;
          } catch (e) {
              console.log(e);
          }
      }
  }
  </code></pre>
  
  <p><strong>And this one is the code for displaying the data on the homepage:</strong></p>
  
  <pre><code>&lt;View&gt; { this.state.pinjams.length &gt; 0 
  ? &lt;PinjamList pinjams={this.state.pinjams} /&gt; 
  : &lt;Text&gt;Tidak Ada Peminjaman&lt;/Text&gt; } &lt;/View&gt;
  </code></pre>
  
  <p><strong>But when I try to test it to make sure if its right, this error shown:</strong> </p>
  
  <blockquote>
    <p>Network request failed<br>
    - node_modules\react-native\Libraries\vendor\core\whatwg-fetch.js:504:29 in onerror<br>
    - node_modules\event-target-shim\lib\event-target.js:172:43 in dispatchEvent<br>
    - ... 8 more stack frames from framework internals  </p>
  </blockquote>