Registry / storage / redux-rest-adapter

redux-rest-adapter

JSON →
library2.0.7jsnpmunverified

A library for connecting REST APIs to Redux store without writing reducers and actions manually. Version 2.0.7 is stable, based on axios and promise-middleware. Compatible with json:api specification. Provides EntityApi class to generate CRUD actions and reducers automatically. Differentiates from other Redux REST libraries by its simplicity and promise-based async handling. Low maintenance and few downloads, but functional for basic CRUD needs.

npm install redux-rest-adapter
INSTALL
IMPORT
SIG · REDUX-REST-ADAPTER
R
redux-rest-adapter
storagejavascriptv2.0.7
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.

EntityApi
import EntityApi from 'redux-rest-adapter'
const { EntityApi } = require('redux-rest-adapter')
Default export is EntityApi class. CommonJS require works too.
promiseMiddleware
import { promiseMiddleware } from 'redux-rest-adapter'
import promiseMiddleware from 'redux-rest-adapter'
Named export for the middleware.
default (EntityApi)
import EntityApi from 'redux-rest-adapter'
import * as EntityApi from 'redux-rest-adapter'
Use default import for the class.

Setup basic EntityApi for tags, combine reducer, apply promiseMiddleware, and dispatch load action.

import EntityApi, { promiseMiddleware } from 'redux-rest-adapter'; import { createStore, applyMiddleware, combineReducers } from 'redux'; const tagsApi = new EntityApi({ entityName: 'TAG', endpointUrl: 'api/v2/tags' }); const apiReducer = combineReducers({ TAG: tagsApi.configureReducer() }); const store = createStore( combineReducers({ api: apiReducer }), {}, applyMiddleware(promiseMiddleware()) ); store.dispatch(tagsApi.actions.load()).then(() => { console.log(store.getState().api.TAG.data); // [{id:1, name:'tag1'}, {id:2, name:'tag2'}]; });
Debug
Known issues
breakingVersion 2.0.0 changed from custom HTTP client to axios. Old v1 configurations incompatible.
fix
Upgrade code to use axios-based API. Refer to changelog.
affects: >=2.0.0
deprecatedThe library is in maintenance mode; no new features expected.
fix
Consider using Redux Toolkit Query or React Query for modern apps.
affects: all
gotchapromiseMiddleware must be applied to the store; omitting it causes actions to not work.
fix
Always include promiseMiddleware in applyMiddleware.
affects: >=2.0.0
gotchaEntityApi assumes JSON API specification; endpoints must follow RESTful conventions. Custom URL patterns may need workarounds.
fix
Override buildURL or use custom axios instance if needed.
affects: all
Errors
Common errors & fixes
Uncaught TypeError: Cannot read properties of undefined (reading 'then')
promiseMiddleware not applied to the store, or actions are not promises.
fix
Ensure promiseMiddleware is in applyMiddleware: applyMiddleware(promiseMiddleware())
Actions must be plain objects. Use custom middleware for async actions.
Redux expects plain objects; async actions need middleware. promiseMiddleware missing.
fix
Add promiseMiddleware to applyMiddleware.
Unexpected key 'data' in reducer
Reducer shape from configureReducer() may conflict with other reducers if not nested under 'api' key.
fix
Ensure the reducer is combined under a key (e.g., 'api') as shown in docs.
Upgrade
Version history
2.0.7latest on npm
Audit
Dependencies
axiosrequiredUsed for HTTP requests since v2.0.0
promise-middlewarerequiredRedux middleware required for promise-based actions
Agent activity
21 hits · last 30 days
node
18
Amazon
1
Resources
redux-rest-adapter — npm install redux-rest-adapter · libregistry