title: Checking for content using fetch
body: <p>I'm using fetch to make API calls which return JSON data.</p>
  
  <p>Sometimes the API call returns a status <code>OK</code> and <code>null</code> for content. I was relying on checking the status to get the content but this gives me an error because there's no JSON data.</p>
  
  <p>The error I'm getting is: <code>Uncaught (in promise) SyntaxError: Unexpected end of JSON input</code></p>
  
  <p>Here's my typical fetch pattern and clearly I need to improve it by adding one more check for JSON data. How should I modify this?</p>
  
  <pre><code>export const getSomeData = () =&gt; {
  
      return (dispatch) =&gt; fetch('/api/myapifunction', fetchOptionsGet())
          .then((response) =&gt; {
              if(response.ok) {
                  // I need to add logic here to check for JSON data before calling parseJSON
                  parseJSON(response)
                  .then(data =&gt; {
                      // Do something
                  })
              } else {
                  // Failed
                  // Handle failure
              }
          })
  }
  </code></pre>
  
  <p>I created functions for fetchOptions such as GET or POST as well as parseJSON. They're simple functions. This is what parseJSON looks like:</p>
  
  <pre><code>export const parseJSON = (response) =&gt; {
      return response.json();
  }
  </code></pre>
  
  <p>As I understand it, response.json() is simply a promise, not necessarily data. How do I check to see if I'm getting any JSON data?</p>