Has axios extra (axios interceptors) used by most business scenarios
- 🔄 Response Handling - Customize and transform API responses
- 🚦 Loading States - Automatic loading state management
- 🧹 Parameter Filtering - Remove unnecessary parameters from requests
- 🔑 Authentication - Handle token refresh and auth headers
- 🔁 Request Optimization - Caching, retrying, and request packing
I'm tired of duplicate code and scattered packages. so. I decided to create a collection of axios interceptors that can be used in various business scenarios.
npm install axios-extras
import axios from 'axios'
import { withParamsExtra } from 'axios-extras'
// Add extra parameters to request headers
withParamsExtra(axios, () => ({ token: localStorage.getItem('token') }), 'headers')
- withAssignResponse - Assign response data to specified properties
- withLoadingHelper - Manage loading state automatically
- withParamsFilter - Filter request parameters
- withParamsExtra - Add extra parameters to requests
- withErrorCustom - Customize response error handling
- withErrorHelper - Global error handling
- withAuthRefresh - Token refresh handling
- withRequestRetry - Automatic request retry
- withRequestPacker - Wrap axios request methods
- withRequestCaches - Cache identical requests