{"library":"redux-api-middleware-fixed","title":"Redux API Middleware (Fixed Fork)","description":"redux-api-middleware-fixed is a Redux middleware designed for declarative API calls. It intercepts specific Redux Standard API-calling Actions (RSAAs), identified by a `[CALL_API]` property, and dispatches Flux Standard Actions (FSAs) during the request lifecycle (request, success, failure). This package is a community-maintained fork, currently at version 2.0.0, addressing outstanding pull requests and maintaining the original `redux-api-middleware` codebase. Its primary differentiator is providing a consistent, action-based pattern for managing API side effects within a Redux application, simplifying data fetching and error handling by abstracting away the boilerplate often associated with `fetch` or `axios` calls within Redux thunks or sagas. The release cadence appears infrequent, primarily driven by maintenance needs rather than active feature development.","language":"javascript","status":"maintenance","last_verified":"Thu Apr 23","install":{"commands":["npm install redux-api-middleware-fixed"],"cli":null},"imports":["import { apiMiddleware } from 'redux-api-middleware-fixed';","import { CALL_API } from 'redux-api-middleware-fixed';","import { isRSAA } from 'redux-api-middleware-fixed';"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import { createStore, applyMiddleware, combineReducers } from 'redux';\nimport { apiMiddleware, CALL_API } from 'redux-api-middleware-fixed';\n\n// A dummy reducer\nconst dataReducer = (state = { loading: false, users: [], error: null }, action) => {\n  switch (action.type) {\n    case 'FETCH_USERS_REQUEST':\n      return { ...state, loading: true, error: null };\n    case 'FETCH_USERS_SUCCESS':\n      return { ...state, loading: false, users: action.payload.users };\n    case 'FETCH_USERS_FAILURE':\n      return { ...state, loading: false, error: action.payload, users: [] };\n    default:\n      return state;\n  }\n};\n\nconst rootReducer = combineReducers({\n  data: dataReducer\n});\n\n// Configure the Redux store with apiMiddleware\nconst store = createStore(rootReducer, applyMiddleware(apiMiddleware));\n\n// Define an API call action\nconst fetchUsers = () => ({\n  [CALL_API]: {\n    endpoint: 'https://jsonplaceholder.typicode.com/users',\n    method: 'GET',\n    types: ['FETCH_USERS_REQUEST', 'FETCH_USERS_SUCCESS', 'FETCH_USERS_FAILURE']\n  }\n});\n\n// Dispatch the action\nstore.dispatch(fetchUsers());\n\n// You can subscribe to store changes to see the state updates\nconst unsubscribe = store.subscribe(() => {\n  console.log('Current state:', store.getState().data);\n});\n\n// In a real application, you'd typically handle errors and unmount subscriptions\n// setTimeout(() => unsubscribe(), 5000);\n","lang":"javascript","description":"Demonstrates setting up a Redux store with `redux-api-middleware-fixed` and dispatching a basic API call action to fetch users.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}