title: How to return the json response from the fetch API
body: <p>I have a function like so:</p>
  
  <pre><code>check_auth(){
      fetch(Urls.check_auth(), {
        credentials: 'include',
        method: 'GET'
      }).then(response =&gt; {
        if(response.ok) return response.json();
      }).then(json =&gt; {
        return json.user_logged_in;
      });
    }
  </code></pre>
  
  <p>And then I try to do this:</p>
  
  <pre><code>if(this.check_auth()){
      // do stuff
  } else {
      // do other stuff
  }
  </code></pre>
  
  <p>But, <code>this.check_auth()</code> is always <code>undefined</code>.</p>
  
  <p>What am I missing here? I thought that within fetch's <code>then()</code> was where the <strong>resolved</strong> Promise object was therefore I thought that I'd get <code>true</code> when the user was logged in. But this is not the case.</p>
  
  <p>Any help would be greatly appreciated.</p>