title: Pass Fetch Request to another Fetch Request in React Native
body: <p>I'm fairly new to react native so be gentle please. I have a double fetch request inside componentDidMount which works as expected:</p>
  
  <pre><code>  componentDidMount() {
  
      const auth = new Buffer('username:HASHGOESHERE');
      const token = auth.toString('base64');
      const authHeader = 'Basic ' + token;
  
  
  fetch('https://example.com/api-connect/get-token.php', {
    method: 'POST',
    headers: {
      'Authorization': authHeader,
      'Content-Type': 'application/json'
    },
  }).then((response) =&gt; response.json())
  .then((responseText) =&gt; {
  
    if (responseText.status.status === 'success'){
  
      fetch('https://example.com/api-connect/send-request.php?action=get_faq', {
        method: 'POST',
        headers: {
          'Authorization': 'Bearer ' + responseText.payload.access_token,
          'Content-Type': 'application/json',
        },
      })
      .then((response) =&gt; response.json())
      .then((responseData) =&gt; {
  
        this.setState({
          isLoading: false,
          faqs: responseData.payload.faqs,
        });
  
      })
  
    }else{
      alert('Something has gone wrong.');
    }
  
  })
  
  }
  </code></pre>
  
  <p>I have to use the get token fetch request everytime i need to make a fetch request throughout my app. I was wondering if there is a way to set up the get token fetch request (maybe in a different file) so i can call/import it when i need, then pass a second fetch to it somehow rather than having to write all my fetch requests as above.</p>
  
  <p>Hopefully what i'm asking makes sense - i can provide more code if needed.</p>
  
  <p>Thanks in advance</p>