Registry / devops / redux-rest-tools

redux-rest-tools

JSON →
library0.7.3jsnpmunverified

An opinionated library for handling REST API calls in Redux apps, providing action creators, reducer generation, state normalization, and a middleware for async request flow. Current version 0.7.3, stable. Release cadence is low; last release was in 2017. Key differentiators: uses redux-actions for FSA-compliant actions, immutable.js for normalized state shape (result, entities, ui, errors), and axios for HTTP. Designed for performance and state consistency.

npm install redux-rest-tools
INSTALL
IMPORT
SIG · REDUX-REST-TOOLS
R
redux-rest-tools
devopsjavascriptv0.7.3
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

createRestActions
import { createRestActions } from 'redux-rest-tools'
const createRestActions = require('redux-rest-tools').createRestActions
Package ships CJS, no ESM; require works but named import from default is common mistake.
createRestReducer
import { createRestReducer } from 'redux-rest-tools'
import createRestReducer from 'redux-rest-tools'
Not a default export; must use named import.
restMiddleware
import { restMiddleware } from 'redux-rest-tools'
import { middleware } from 'redux-rest-tools'
Export name is restMiddleware, not middleware.

Basic setup: create REST actions, reducer, apply middleware, dispatch request.

import { createStore, applyMiddleware, combineReducers } from 'redux'; import { createRestActions, createRestReducer, restMiddleware } from 'redux-rest-tools'; const usersActions = createRestActions('FETCH_USERS', { url: '/api/users' }); const usersReducer = createRestReducer('users', { idPath: 'id' }); const store = createStore( combineReducers({ users: usersReducer }), applyMiddleware(restMiddleware) ); store.dispatch(usersActions.request({}, { onSuccess: (result) => console.log(result) }));
Debug
Known issues
gotchaPackage uses immutable.js; state slices are immutable Maps, but Redux store root does not have to be immutable. Mixing immutable and plain JS can cause confusion.
fix
Use Immutable.is() for equality checks or convert to JS with toJS() cautiously.
affects: >=0.1.0
deprecatedPackage last updated in 2017; relies on older versions of redux-actions (v1) and axios (v0.16). Breaking changes in newer versions may break compatibility.
fix
Pin versions: redux-actions@1, axios@0.16, immutable@3.8.
affects: >=0.7.0
gotchacreateRestActions expects endpoint as url in options; does not support dynamic URLs via action payload. Will always hit the same URL.
fix
Use onSuccess to modify state or manually dispatch success action with custom data.
affects: >=0.1.0
gotchaNormalized state shape uses result as array of IDs; entities are stored by ID. Directly accessing nested entity fields without lookup may fail.
fix
Always access entities via state.getIn(['entities', id]) or toJS() then bracket notation.
affects: >=0.1.0
gotchaMiddleware uses axios defaults; global axios interceptors will affect all requests. Cannot configure per-request options beyond url and method.
fix
Configure axios instance globally before using middleware.
affects: >=0.1.0
Errors
Common errors & fixes
Cannot find module: 'redux-rest-tools'
Package not installed or incorrect import path
fix
npm install redux-rest-tools@0.7.3 --save
TypeError: (0 , _reduxRestTools.createRestActions) is not a function
Using default import instead of named import
fix
import { createRestActions } from 'redux-rest-tools'
Uncaught Error: Expected a plain object for action payload but got Immutable.Map
Dispatch an action with immutable Map payload directly; redux-actions expects plain objects
fix
Convert immutable Map to plain JS using toJS() before dispatching
Upgrade
Version history
0.7.3latest on npm
Audit
Dependencies
reduxrequiredCore peer dependency for Redux store
redux-actionsrequiredFSA-compliant action creation
immutablerequiredImmutable data structures for state
axiosrequiredHTTP client for requests
Agent activity
7 hits · last 30 days
node
6
Amazon
1
Resources
redux-rest-tools — npm install redux-rest-tools · libregistry