title: Getting API response payload using fetch
body: <p>I am using fetch to get the API response for GET and POST requests. When an error occurs, I am able to see the status code and the text i.e, 400 Bad Request. However, there is additional information being passed that explains why the error was thrown (i.e. username did not match). I can see this additional message in the response payload via Firefox developer tool's console but I am not sure how to get it via handling the fetch response.</p>
  
  <p>Here's an example request:</p>
  
  <pre><code>fetch(url, {
    method: 'POST',
    body: JSON.stringify({
      name: name,
      description: description
    }),
    headers: {
      "Content-type": "application/json; charset=UTF-8",
      "Authorization": "Bearer " + token
    }
  }).then(response =&gt; {
    if (!response.ok) {
      throw Error(response.statusText)
  
    }
    return response
  })
  .catch(error =&gt; {
    console.log(error)
  })
  </code></pre>
  
  <p>Any ideas? Thanks.</p>