title: Handling non JSON response with a Body.json() promise
body: <p>I'm trying to create a scheme to intercept and handle requests from an API middleware, however, for whatever reason I'm unable to properly handle non JSON responses from my API endpoint. The following snippet works just fine for server responses formatted in JSON however say an user has an invalid token, the server returns a simple Unauthorized Access response that I'm unable to handle even though I am supplying an error callback to the json() promise. The Unauthorized Access response message is lost in the following scheme. </p>
  
  <pre><code>    const callAPI = () =&gt; { fetch('http://127.0.0.1:5000/auth/', {
          method: 'GET',
          headers: {
              'credentials': 'include',
              'Accept': 'application/json',
              'Content-Type': 'application/json',
              'Authorization': 'Basic bXlKaGJHY2lPaUpJVXpJMU5pSXNJbVY0Y0NJNk1UUTVPRE15TVRNeU5pd2lhV0YwSWpveE5EazRNak0wT1RJMmZRLmV5SnBaQ0k2TVgwLllFdWdKNF9YM0NlWlcyR2l0SGtOZGdTNkpsRDhyRE9vZ2lkNGVvaVhiMEU6'
          }
      });
      };
  
      return callAPI().then(res =&gt; {
          return res.json().then(responseJSON =&gt; {
              if(responseJSON.status === 200){
                  return dispatch({
                      type: type[1],
                      data: responseJSON,
                      message: success
                  });
              } else if(responseJSON.status === 401) {
                  return dispatch({
                      type: type[2],
                      message: responseJSON.message
                  });
              }
              return Promise.resolve(json);
          }, (err) =&gt; {
              console.log(err.toString(), ' an error occured');
          });
      }, err =&gt; {
          console.log('An error occured. Please try again.');
      });
  </code></pre>