Registry / devops / redux-axios

redux-axios

JSON →
library0.0.2jsnpmunverified

redux-axios is a Redux middleware that intercepts actions with a payload.request property and dispatches corresponding success/failure actions based on Axios responses. At version 0.0.2, it is an early-stage, unmaintained package with no recent releases. It differentiates itself by allowing per-action client selection and promise chaining on dispatch. However, it lacks TypeScript definitions, has undocumented side effects, and is not compatible with modern Redux toolkits.

npm install redux-axios
INSTALL
IMPORT
SIG · REDUX-AXIOS
R
redux-axios
devopsjavascriptv0.0.2
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.

axiosMiddleware (default export)
import axiosMiddleware from 'redux-axios';
import { axiosMiddleware } from 'redux-axios';
The only export is a default function. Named import will yield undefined.
commonjs require
const axiosMiddleware = require('redux-axios').default;
const axiosMiddleware = require('redux-axios');
Package does not set module.exports directly; use .default for CJS.
TypeScript usage
import axiosMiddleware from 'redux-axios';
No type definitions exist; you may need a .d.ts declaration: declare module 'redux-axios';

Shows how to set up the redux-axios middleware with a custom Axios instance and dispatch an action that triggers an HTTP request.

import { createStore, applyMiddleware } from 'redux'; import axiosMiddleware from 'redux-axios'; import axios from 'axios'; // Create an Axios instance const client = axios.create({ baseURL: 'https://api.example.com', responseType: 'json' }); // Define a reducer const reducer = (state = {}, action) => { switch (action.type) { case 'FETCH_USER_SUCCESS': return { ...state, user: action.payload.data }; default: return state; } }; // Create the store with middleware const store = createStore( reducer, applyMiddleware( axiosMiddleware(client, { successSuffix: '_SUCCESS', errorSuffix: '_FAIL' }) ) ); // Dispatch an action with payload.request store.dispatch({ type: 'FETCH_USER', payload: { request: { url: '/users/1' } } });
Debug
Known issues
gotchaThe package is at version 0.0.2 (pre-1.0.0) and appears abandoned (last commit years ago). Breaking changes may occur with any minor version bump.
fix
Consider using axios in a custom middleware or a maintained alternative like redux-axios-middleware.
affects: >=0.0.0
breakingThe action payload must contain a 'request' property; otherwise the action passes through unmodified. Omitting 'request' silently skips the middleware.
fix
Ensure every action intended for HTTP has payload.request defined.
affects: >=0.0.0
gotchaThe default export is a function that expects an Axios instance and an options object. Using a plain config object instead of an Axios instance will throw an error.
fix
Pass an axios instance (created via axios.create()) as the first argument.
affects: >=0.0.0
gotchaIf no client key is specified in the action payload, the middleware tries to use a 'default' key from the clients map. If no default client exists, it throws.
fix
Ensure your client map has a 'default' key or always specify a valid client name.
affects: >=0.0.0
deprecatedThe middleware does not support modern Redux patterns like createAsyncThunk or RTK Query. Using with Redux Toolkit may require additional custom middleware.
fix
Consider migrating to a more modern Redux async solution.
affects: >=0.0.0
Errors
Common errors & fixes
Cannot read property 'default' of undefined
CommonJS require does not automatically resolve the default export.
fix
Use: const axiosMiddleware = require('redux-axios').default;
TypeError: client.request is not a function
First argument to axiosMiddleware must be an Axios instance, not a config object.
fix
Create an Axios instance first: const client = axios.create({...});
Uncaught Error: Actions must be plain objects. Use custom middleware for async actions.
The action dispatched does not have a payload.request property, so redux-axios does not handle it, but another middleware expected a plain object.
fix
Add payload.request to the action object.
Upgrade
Version history
0.0.2latest on npm
Audit
Dependencies
axiosrequiredPeer dependency for HTTP requests; must be installed separately.
Agent activity
6 hits · last 30 days
node
6
Resources
redux-axios — npm install redux-axios · libregistry