{"library":"redux-api-middleware-interceptor","title":"Redux API Middleware Interceptor","description":"A Redux middleware that wraps redux-api-middleware to intercept API calls, allowing automatic header injection (e.g., JWT), base URL prepending, and callbacks for request lifecycle events (init, success, failure). Works with redux-api-middleware ^2.0.0 and Redux's applyMiddleware. Simple API: pass a config object to the exported function. Two releases: 1.0.4 is current stable. Not frequently updated, but functional for its niche.","language":"javascript","status":"active","last_verified":"Sat Apr 25","install":{"commands":["npm install redux-api-middleware-interceptor"],"cli":null},"imports":["import interceptor from 'redux-api-middleware-interceptor'","import { CALL_API } from 'redux-api-middleware'","import { applyMiddleware, createStore } from 'redux'"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import { applyMiddleware, createStore } from 'redux';\nimport thunk from 'redux-thunk';\nimport interceptor from 'redux-api-middleware-interceptor';\nimport { CALL_API, apiMiddleware } from 'redux-api-middleware';\n\nconst store = createStore(\n  reducer,\n  applyMiddleware(\n    interceptor({\n      headers: (origHeaders, state) => ({\n        ...origHeaders,\n        Authorization: state.auth?.jwt ? `Bearer ${state.auth.jwt}` : '',\n      }),\n      getURL: (url, state) => `https://api.example.com${url}`,\n      onRequestInit: (state) => console.log('API request started'),\n      onRequestSuccess: (state, response) => console.log('API request succeeded', response),\n      onRequestFail: (state, error) => console.error('API request failed', error),\n    }),\n    apiMiddleware,\n    thunk\n  )\n);\n\n// Usage: dispatch an RSAA action as usual\nstore.dispatch({\n  [CALL_API]: {\n    endpoint: '/users',\n    method: 'GET',\n    types: ['REQUEST', 'SUCCESS', 'FAILURE']\n  }\n});","lang":"javascript","description":"Shows complete setup: interceptor middleware injected before apiMiddleware, with custom headers, base URL, and lifecycle callbacks.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}