JavaScript fetch API - Why does response.json() return a promise object (instead of JSON)?
<p>I've just started to learn the Fetch API: <a href="https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch" rel="noreferrer">https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch</a></p>

<p>Here's a code snippet which I wrote to tinker around with it:</p>

<pre><code>fetch('http://swapi.co/api/people/1')
  .then(function(response) {
    var json = response.json();

    console.log(json);
    // Expected : { "name": "Luke Skywalker","height": "1.72 m", ... } 
    // Get : Promise {[[PromiseStatus]]: "pending", [[PromiseValue]]: undefined}
  }); 
</code></pre>

<p>I would have expected to get an JSON object out of response.json().</p>

<p>Similar to what you get when using JSON.parse(). </p>

<p>Instead I get a promise object. </p>

<p>If I enlarge the promise chain like shown here ... </p>

<pre><code>return response.json().then(function(json) {
      // process your JSON further
});
</code></pre>

<p>... then it works: Within the then method of the following promise it appears as json.</p>

<p><strong>Why can't I retrieve the JSON data within the then() of the first promise?</strong></p>

<p>Can anyone please explain what is going on here?</p>

<p>I would really much appreciate it.</p>