b2k-redux-api-middleware

Redux middleware for handling api requests


Keywords
redux, middleware, api, request
License
MIT
Install
npm install b2k-redux-api-middleware@0.0.2

Documentation

redux-api-middleware

middleware for handling api requests

Usage

npm install --save b2k-redux-api-middleware

import { getApiReducer, baseState, initial, load, success, fail, reset } from '@baohx2000/redux-api-middleware';
// Only getApiReducer is actually needed.  The rest are just basic helper objects & methods

const myReducer = getApiReducer(
  'MYACTION', // base action string,
  baseState, // base state for reducer... note there are many objects included to help compose this base
  initial, // Reducer called upon initial api call
  load, // reducer called immediately after initial call
  success, // called with response from successful call
  fail, // called with response from unsuccessful call (>= 400)
  reset // Call manually to reset the store
);