Skip to content

Instantly share code, notes, and snippets.

@iamdustan
Created October 2, 2015 13:45
Show Gist options
  • Save iamdustan/8a3303c43767fa0ef64d to your computer and use it in GitHub Desktop.
Save iamdustan/8a3303c43767fa0ef64d to your computer and use it in GitHub Desktop.
// our apis return successfully from an HTTP/fetch promise standpoint for
// response payloads with error codes. We would like the reducer to receive this
// an rejection and not have to manage unwrapping that itself.
export default () => next => action =>
action.type === 'FETCH'
? next(action).then(res => res.hasOwnProperty('error') ? Promise.reject(res) : res)
: next(action);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment