title: How to check if the response of a fetch is a json object in javascript
body: <p>I'm using fetch polyfill to retrieve a JSON or text from a URL, I want to know how can I check if the response is a JSON object or is it only text </p>
  
  <pre><code>fetch(URL, options).then(response =&gt; {
     // how to check if response has a body of type json?
     if (response.isJson()) return response.json();
  });
  </code></pre>