axios-extras
v3.1.0
Published
Has axios extra (axios interceptors) used by most business scenarios
Readme
🛹 Axios Extras
Has axios extra (axios interceptors) used by most business scenarios
✨ Features
- 🔄 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
💬 Why?
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.
📦 Install
npm install axios-extras🚀 Usage
import axios from 'axios'
import { withParamsExtra } from 'axios-extras'
// Add extra parameters to request headers
withParamsExtra(axios, () => ({ token: localStorage.getItem('token') }), 'headers')🛠️ Methods
- 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
