title: Handling unauthorized request in react-query
body: <p>I'm having problems using react-query. Whenever the response from the server is Unauthorized, useQuery is returning flags status='success' and isError=false. The server response status is 401 and the content of the json response is <code>{ error: true, message: 'UNAUTHORIZED' }</code>. I didn't customize react-query in any way.</p>
  <p>I'm not using the <em>ReactQueryConfigProvider</em>, or passing any options in the call to customize the behaviour.</p>
  <p>This is the call:</p>
  <pre><code>const { status, data, error } = useQuery(
    [&quot;hotelsList&quot;, { token: token }],
    getHotels
  );
  </code></pre>
  <p>And this is the service:</p>
  <pre><code>const getHotels = async ({ token }) =&gt; {
    const uri = process.env.REACT_APP_API_ENDPOINT_v2 + `/hotels`
    return (await fetch(uri, {
      method: &quot;get&quot;,
      headers: {
        Authorization: &quot;Bearer &quot; + token,
        &quot;Content-Type&quot;: &quot;application/json&quot;
      }
    })).json()
  }
  </code></pre>
  <p>Being the token invalid, the server is responding with an 401 status code and my custom json response.</p>
  <p><a href="https://i.stack.imgur.com/2uzzq.png" rel="noreferrer"><img src="https://i.stack.imgur.com/2uzzq.png" alt="Response code from server is 401" /></a></p>
  <p>This is the data and error objects from react-query.</p>
  <p><a href="https://i.stack.imgur.com/wX4wq.png" rel="noreferrer"><img src="https://i.stack.imgur.com/wX4wq.png" alt="Objects returned by useQuery" /></a></p>