title: JS - fetch API, GET method return "ƒ json() { [native code] }"
body: <p>I woud like to understand the difference between the two get methods, one work, the other not really but i don t understand why.</p>
  
  <p><strong>This doesn't work:</strong></p>
  
  <pre><code>fetch('https://glo3102lab4.herokuapp.com/fee958c0-c320-40d0-a750-218f2d7c1303/tasks', {
      method: 'GET',
  }).then(res =&gt; res.json)
      .catch(error =&gt; {
          console.error('Error:', error);
      })
      .then(response =&gt; {
          console.log(response);
      });
  </code></pre>
  
  <p>and return :</p>
  
  <blockquote>
    <p>ƒ json() { [native code] }</p>
  </blockquote>
  
  <p><strong>This works well:</strong></p>
  
  <pre><code>fetch('https://glo3102lab4.herokuapp.com/fee958c0-c320-40d0-a750-218f2d7c1303/tasks').then(function(response){
      response.json().then(function(data) {
          console.log(data);
      });
  }).catch(function(error) {
      console.log('Fetch Error:', error);
  });
  </code></pre>
  
  <p>and return:</p>
  
  <blockquote>
    <p>{tasks: Array(4)} tasks : (4) [{…}, {…}, {…}, {…}]
    <strong>proto</strong> : Object</p>
  </blockquote>
  
  <p><strong>If you want to try it:</strong>
  <div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>fetch('https://glo3102lab4.herokuapp.com/fee958c0-c320-40d0-a750-218f2d7c1303/tasks', {
          method: 'GET',
      }).then(res =&gt; res.json)
          .catch(error =&gt; {
              console.error('Error:', error);
          })
          .then(response =&gt; {
              console.log("first way");
              console.log(response);
          });
          
  fetch('https://glo3102lab4.herokuapp.com/fee958c0-c320-40d0-a750-218f2d7c1303/tasks').then(function(response){
          response.json().then(function(data) {
              console.log("second way");
              console.log(data);
          });
      }).catch(function(error) {
          console.log('Fetch Error:', error);
      });</code></pre>
  </div>
  </div>
  </p>