Registry /
http-networking / redux-api-middleware-interceptor
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslnode 18–226 runs
build_error
glibcnode 18–226 runs
build_error
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
interceptor
✓ import interceptor from 'redux-api-middleware-interceptor'
✗ const interceptor = require('redux-api-middleware-interceptor').default
Default export as a function. CommonJS users must require the module directly: const interceptor = require('redux-api-middleware-interceptor') and it will work directly (no .default needed).
CALL_API
✓ import { CALL_API } from 'redux-api-middleware'
✗ import { CALL_API } from 'redux-api-middleware-interceptor'
CALL_API is re-exported from the parent package, not from interceptor. Always import from redux-api-middleware.
applyMiddleware / createStore
✓ import { applyMiddleware, createStore } from 'redux'
✗ import { applyMiddleware, createStore } from 'redux-api-middleware-interceptor'
Standard Redux exports; not part of interceptor package.
Shows complete setup: interceptor middleware injected before apiMiddleware, with custom headers, base URL, and lifecycle callbacks.
import { applyMiddleware, createStore } from 'redux';
import thunk from 'redux-thunk';
import interceptor from 'redux-api-middleware-interceptor';
import { CALL_API, apiMiddleware } from 'redux-api-middleware';
const store = createStore(
reducer,
applyMiddleware(
interceptor({
headers: (origHeaders, state) => ({
...origHeaders,
Authorization: state.auth?.jwt ? `Bearer ${state.auth.jwt}` : '',
}),
getURL: (url, state) => `https://api.example.com${url}`,
onRequestInit: (state) => console.log('API request started'),
onRequestSuccess: (state, response) => console.log('API request succeeded', response),
onRequestFail: (state, error) => console.error('API request failed', error),
}),
apiMiddleware,
thunk
)
);
// Usage: dispatch an RSAA action as usual
store.dispatch({
[CALL_API]: {
endpoint: '/users',
method: 'GET',
types: ['REQUEST', 'SUCCESS', 'FAILURE']
}
});
Errors
Common errors & fixes
Uncaught Error: [redux-api-middleware-interceptor] getURL must be a function
getURL config property is provided but is not a function (e.g., string or object).
fixChange getURL to a function: getURL: (url, state) => `https://example.com${url}` Uncaught TypeError: interceptor is not a function
Importing default export incorrectly in CommonJS or forgetting to call interceptor().
fixUse const interceptor = require('redux-api-middleware-interceptor'); then call interceptor({...}) as function. TypeError: Cannot read property 'jwt' of undefined
State shape does not match expectations: trying to access state.auth.jwt but auth reducer is not at that path.
fixCheck your store's state tree and adjust the headers function to access state.auth?.jwt or equivalent.
Audit
Dependencies
redux-api-middlewarerequiredPeer dependency – this package acts as a wrapper around its middleware.