title: Whatwg Fetch fails when json parsing an empty response, how can I prevent it?
body: <p>I'm using the Fetch API both in the frontend and on the backend (NodeJS), a problem that I've been facing a lot happens when parsing the response as json.</p>
  
  <p><code>response.json()</code> will return a promise so I don't know beforehand what the body of the response is, and when the body is empty the JSON parsing will fail with the error:</p>
  
  <p><code>SyntaxError: Unexpected end of input</code></p>
  
  <p>So my question is, how to prevent parsing the response when its empty?</p>
  
  <p>Thanks</p>