How to .catch a Promise.reject : <p>I have a helper function for using <code>fetch</code> with CouchDB which ends as:</p>

<pre><code>...
return fetch(...)
  .then(resp =&gt; resp.ok ? resp.json() : Promise.reject(resp))
  .then(json =&gt; json.error ? Promise.reject(json) : json)
</code></pre>

<p>and when I use it elsewhere, I was under the impression that I could <code>.catch</code> those explicit rejections:</p>

<pre><code>  above_function(its_options)
    .then(do_something)
    .catch(err =&gt; do_something_with_the_json_error_rejection_or_resp_not_ok_rejection_or_the_above(err))
</code></pre>

<p>but alas, I can't seem to be able to get a hold of the rejections.
The specific error I'm after is a HTTP 401 response.</p>

<p>What gives?</p>

<p>(Please note that there are implicit ES6 <code>return</code>'s in the <code>.then</code>s)</p>
