title: How to get data returned from fetch() promise?
body: <p>I am having trouble wrapping my head around returning json data from a fetch() call in one function, and storing that result in a variable inside of another function. Here is where I am making the fetch() call to my API:</p>
  
  <pre><code>function checkUserHosting(hostEmail, callback) {
      fetch('http://localhost:3001/activities/' + hostEmail)
      .then((response) =&gt; { 
          response.json().then((data) =&gt; {
              console.log(data);
              return data;
          }).catch((err) =&gt; {
              console.log(err);
          })
      });
  }
  </code></pre>
  
  <p>And this is how I am trying to get the returned result:</p>
  
  <pre><code>function getActivity() {
      jsonData = activitiesActions.checkUserHosting(theEmail)
  }
  </code></pre>
  
  <p>However, <code>jsonData</code> is always <code>undefined</code> here (which I am assuming is because the async fetch call has not finished yet when attempting to assign the returned value to <code>jsonData</code>. How do I wait long enough for the data to be returned from the fetch call so that I can properly store it inside of <code>jsonData</code>?</p>