{"id":18730,"library":"redux-shapeshifter-middleware","title":"Redux Shapeshifter Middleware","description":"Redux middleware version 1.3.5 that enhances Redux actions to handle AJAX calls using axios and qs. It allows actions to define API endpoints, methods, payload generators, authentication from Redux store state, and advanced features like ETags, request cancellation, and response transformations. Released under an active maintenance cadence, it differentiates from other Redux async middleware by integrating deeply with axios configuration and supporting generator-based action flows.","status":"active","version":"1.3.5","language":"javascript","source_language":"en","source_url":"https://github.com/dawaa/redux-shapeshifter-middleware","tags":["javascript","redux","shapeshifter","middleware","redux-middleware","action","actions","redux-store","generator-action"],"install":[{"cmd":"npm install redux-shapeshifter-middleware","lang":"bash","label":"npm"},{"cmd":"yarn add redux-shapeshifter-middleware","lang":"bash","label":"yarn"},{"cmd":"pnpm add redux-shapeshifter-middleware","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"HTTP client for making AJAX requests","package":"axios","optional":false}],"imports":[{"note":"ESM default export; CJS require also works but typings may be lost.","wrong":"const shapeshifter = require('redux-shapeshifter-middleware')","symbol":"default","correct":"import shapeshifter from 'redux-shapeshifter-middleware'"},{"note":"The package exports a single function as default. Named import does not exist.","wrong":"import { shapeshifterMiddleware } from 'redux-shapeshifter-middleware'","symbol":"shapeshifterMiddleware","correct":"import shapeshifter from 'redux-shapeshifter-middleware'"},{"note":"There is no named export. Use default import.","wrong":"import { createShapeshifter } from 'redux-shapeshifter-middleware'","symbol":"createShapeshifter","correct":"import shapeshifter from 'redux-shapeshifter-middleware'"}],"quickstart":{"code":"import { createStore, applyMiddleware } from 'redux';\nimport shapeshifter from 'redux-shapeshifter-middleware';\n\nconst apiMiddleware = shapeshifter({\n  base: 'https://api.example.com/',\n  auth: {\n    user: 'token'\n  },\n  fallbackToAxiosStatusResponse: true\n});\n\nconst reducer = (state = {}) => state;\nconst store = createStore(reducer, applyMiddleware(apiMiddleware));\n\n// Dispatch an API action\nstore.dispatch({\n  type: 'FETCH_USER',\n  types: ['FETCH_USER_PENDING', 'FETCH_USER_SUCCESS', 'FETCH_USER_ERROR'],\n  method: 'GET',\n  payload: {\n    url: '/users/123',\n    auth: true\n  }\n});","lang":"javascript","description":"Demonstrates setting up the middleware with a base URL and auth config, then dispatching a GET request action with lifecycle types."},"warnings":[{"fix":"Move the 'types' array from payload to the top-level action object.","message":"{action}.payload.types is deprecated in favor of {action}.types","severity":"breaking","affected_versions":">=0.1.1"},{"fix":"Upgrade to v0.4.1 or later.","message":"The 'errors' array check was fixed in v0.4.1 to only reject when length > 0, but older versions rejected empty arrays.","severity":"deprecated","affected_versions":"<=0.4.0"},{"fix":"Set 'useFullResponseObject: true' in config or action to get the full axios response object.","message":"If 'useFullResponseObject' is not set in action or config, the middleware slices the response to only return data.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Ensure the nested object path exists in state, e.g., state.user.token for auth: { user: 'token' }.","message":"The 'auth' property in config must match a path in the Redux store; otherwise, authentication headers will be undefined.","severity":"gotcha","affected_versions":">=0.5.2"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Add a 'types' array to your action with three strings for pending, success, and error action types.","cause":"Action object does not have a 'types' array at the top level or in payload.","error":"TypeError: Cannot read properties of undefined (reading 'types')"},{"fix":"Ensure the action has a 'payload' property with at least a 'url' string.","cause":"Action payload is not defined or is undefined.","error":"Uncaught (in promise) Error: shapeshifter middleware: payload object is undefined"},{"fix":"Run 'npm install axios' or 'yarn add axios'.","cause":"Axios is not installed as a peer dependency.","error":"Error: shapeshifter middleware: axios is not installed or not passable in config"},{"fix":"Set 'method' to one of: GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONS.","cause":"Action 'method' property is missing or is an invalid HTTP method.","error":"Error: shapeshifter middleware: method must be a valid HTTP method string"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}