title: Managing API calls with default error handling in react-redux application
body: <p>I've completed my application and I'm now integrating the real api calls for each async action. I use <code>redux-thunk</code> which returns a promise from an <code>axios</code> instance.</p>
  
  <p>Currently I'm repeating so much of the same logic in my actions that I'm sure I'm missing something.</p>
  
  <p><strong>API response example</strong></p>
  
  <pre><code>{
      "ok": true,
      "warnings": [],
      "errors": [],
      "response": {/* stuff */}
  }
  </code></pre>
  
  <p>The Idea is that I need the same error handling if either the <code>axios</code> call fails (so another response status then 2xx). Additionally I need to also do the same thing when the api response returns <code>"ok": false</code>. </p>
  
  <p>Preferably I would like to dispatch an action which shows a notification to users so they also know when something goes wrong. Aside from that I want to log the api response's <code>warnings</code> and <code>error</code> entities. This is mainly because I'll use <a href="https://sentry.io/welcome/" rel="nofollow noreferrer">sentry</a> for monitoring.</p>
  
  <p>Any Ideas on how to do this without doing a <code>.catch()</code> with the same logic on each api call in any of my action creators?</p>
  
  <p>I've thought about using the <code>onError</code> of <code>axios</code> but that can't dispatch an action as far as I know.</p>