title: Is it possible to create a reuseable fetch function in React Native?
body: <p>I'm new in React native.</p>
  
  <p>I need to create a reusable fetch function.</p>
  
  <p>So i will explain what i need :</p>
  
  <ol>
  <li><p>I need to fetch Token first</p></li>
  <li><p>I will request other API after get the token</p></li>
  <li><p>Activity number 1 will execute everytime i execute an API.</p></li>
  </ol>
  
  <p>Here my code :</p>
  
  <pre><code>fetch('https://myapi.myurl.com/getToken')
    .then((response) =&gt; response.json())
    .then((responseJson) =&gt; {
     //First API -- Always need to request it to get Token
     fetch('https://myapi.myurl.com/doCheck')
      .then((response) =&gt; response.json())
      .then((responseJson) =&gt; {
  
          //My Second API - this API can be change according to case
  
       });
  
  
      });
  </code></pre>
  
  <blockquote>
    <p>Is it possible to create function that can change second API without
    re-coding first API calling ? How to achieve that ?</p>
  </blockquote>
  
  <p>Thank you.</p>