thunk-error
Instalation
yarn add @breadhead/thunk-error
Usage
import { applyMiddleware, combineReducers, createStore } from 'redux'
import thunk from 'redux-thunk';
import { createErrorMiddleware } from '@breadhead/thunk-error'
export const unauthorizedMiddleware = createErrorMiddleware(
(err) => !!err && (err.status === 401 || err.status === 403),
() => actions.authViolateStatus(),
)
const reducer = combineReducers({
first: firstReducer,
})
const store = createStore(
reducer,
initialState,
applyMiddleware(
unauthorizedMiddleware,
thunk,
),
)