Registry / devops / axios-plugins

axios-plugins

JSON →
library0.6.2jsnpmunverified

A lightweight TypeScript library extending axios with plugin capabilities (debounce, throttle, merge, retry, cancel, cache, envs, loading) while keeping minimal intrusion (1.37kb core gzipped). Current version 0.6.2, uses peer dependency axios (any version). Designed to provide multiple instance support, low integration cost, and extensibility via IPlugin interface. Alternative to manual interceptor management with richer feature set.

npm install axios-plugins
INSTALL
IMPORT
SIG · AXIOS-PLUGINS
A
axios-plugins
devopsjavascriptv0.6.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

useAxiosPlugin
import { useAxiosPlugin } from 'axios-plugins'
const { useAxiosPlugin } = require('axios-plugins')
Library is ESM-first; named import. CommonJS require may still work but not guaranteed.
mock
import { mock } from 'axios-plugins'
import mock from 'axios-plugins'
Default export does not exist; all exports are named.
useAxiosPlugin
import { useAxiosPlugin } from 'axios-plugins/core'
import useAxiosPlugin from 'axios-plugins/core'
Even sub-path exports use named export, not default.

Demonstrates creating an axios instance, attaching the cache plugin, and making a request that uses caching.

import axios from 'axios'; import { useAxiosPlugin, cache } from 'axios-plugins'; const request = axios.create({ baseURL: 'https://api.example.com' }); useAxiosPlugin(request).plugin(cache({ ttl: 5000 })); async function getData() { // First call fetches and caches; subsequent calls within 5s use cache. const res = await request.get('/data', { cache: true }); console.log(res.data); } getData();
Debug
Known issues
gotchawrap() required for use with request() method
fix
After useAxiosPlugin(request).plugin(...), call .wrap() to obtain a new instance that works with request() as well as axios-specific methods like post().
affects: >=0.0.1
gotchaPlugin cache is per-instance: must call useAxiosPlugin on each axios instance separately
fix
For multiple axios instances, call useAxiosPlugin(instance) individually.
affects: >=0.0.1
deprecatedOld import path 'axios-plugins/plugins' may be removed in future versions
fix
Use the new sub-path exports: 'axios-plugins/plugins/loading' instead of 'axios-plugins/plugins'.
affects: >=0.6.0
gotchaPlugins are activated only after .plugin() is called; order matters if multiple plugins interact
fix
Ensure all desired plugins are registered in the correct order before making requests.
affects: >=0.0.1
Errors
Common errors & fixes
TypeError: useAxiosPlugin(...).plugin(...) is undefined
wrap() not called, so returned object is not a full axios instance; plugin registration returns a builder, not an instance.
fix
Chain .wrap() after .plugin() call to obtain the wrapped axios instance.
Error: Cannot find module 'axios-plugins/plugins'
Using deprecated import path; path changed to 'axios-plugins/plugins/loading' etc.
fix
Update import to specific plugin sub-path: e.g., 'axios-plugins/plugins/loading'.
ReferenceError: require is not defined
Package is ESM-only (from v0.6.0), running in a CommonJS environment without ESM support.
fix
Use import syntax, or ensure Node.js version supports ESM and set type: module in package.json.
Upgrade
Version history
0.6.2latest on npm
Audit
Dependencies
axiosrequiredpeer dependency; core HTTP client this library extends
Agent activity
12 hits · last 30 days
node
10
OpenAI (training)
1
Resources
axios-plugins — npm install axios-plugins · libregistry