title: Using fetch() Webapi
body: <p>I am trying to see how browser's native webapi <code>fetch()</code> api works. So far I have this: <a href="https://babeljs.io/repl/#?evaluate=true&amp;lineWrap=true&amp;presets=es2015%2Creact%2Cstage-0%2Cstage-1%2Cstage-2%2Cstage-3&amp;experimental=false&amp;loose=false&amp;spec=false&amp;code=var%20f1%20%3D%20async%20function%20()%20%7B%0A%20%20var%20pulls%20%3D%20await%20fetch(%22https%3A%2F%2Fapi.github.com%2Fusers%2Fajainarayanan%22)%3B%0A%20%20return%20pulls%3B%0A%7D%3B%0Af1().then(pulls%20%3D%3E%20%7B%0A%20%20var%20str%20%3D%20&#39;&#39;%3B%0A%20%20var%20reader%20%3D%20pulls.body.getReader()%3B%0A%0A%20%20reader.read().then(function%20processResult(result)%20%7B%0A%20%20%20%20if%20(result.done)%20%7B%0A%20%20%20%20%20%20let%20profile%20%3D%20JSON.parse(str)%3B%0A%20%20%20%20%20%20console.log(&#39;Profile%3A%20&#39;%2C%20JSON.stringify(profile%2C%20null%2C%20&#39;%20&#39;))%0A%20%20%20%20%20%20console.log(&#39;Done!&#39;)%3B%0A%20%20%20%20%20%20return%3B%0A%20%20%20%20%7D%0A%20%20%20%20result.value.forEach(%20r%20%3D%3E%20str%20%2B%3D%20String.fromCharCode(r)%20)%3B%0A%20%20%20%20%2F%2F%20console.log(&#39;streaming%3A%20&#39;%2C%20str)%3B%20%0A%20%20%20%20return%20reader.read().then(processResult)%3B%0A%20%20%7D)%3B%0A%7D)%3B" rel="nofollow">Sample-Code</a> and it works fine. But what I don't understand why is it streaming string which I have to convert to a JSON? I am not sure why would anybody even need to stream a JSON as string through a REST API? I am pretty sure I am missing something here but I am not sure how I should tell <code>fetch()</code> to get the response as JSON and not as a <code>ReadableByteStream</code> which I have to convert to a string and parse it for a JSON.</p>
  
  <p>My Question is this,</p>
  
  <ol>
  <li>Why is a <code>string</code> being streamed here?</li>
  <li>How do I tell <code>fetch()</code> to fetch my response as text or json so that I can do <code>response.json()</code> or <code>response.text()</code> as mentioned in the <a href="https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch" rel="nofollow">docs</a>? (FYI I tried adding a header object and creating a <code>Header</code> instance and passing it to <code>fetch()</code> neither changed my response.</li>
  </ol>