Registry / http-networking / ax-middleware

ax-middleware

JSON →
library0.4.0jsnpmunverified

A simple middleware service for axios HTTP requests. Version 0.4.0 is the final release as the package is deprecated. It allows intercepting axios requests and responses via middleware functions, supporting async handlers and custom adapters. Key differentiators: a clean middleware pattern with onRequest/onResponse/onSync hooks, vs axios's native interceptors. Requires axios >=0.17.1 <1.2.0. The package is unmaintained and alternatives should be considered.

npm install ax-middleware
INSTALL
IMPORT
SIG · AX-MIDDLEWARE
A
ax-middleware
http-networkingjavascriptv0.4.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

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

HttpMiddlewareService
import { HttpMiddlewareService } from 'axios-middleware'
const axiosMiddleware = require('axios-middleware')
ESM import for the service class.
Service
import { Service } from 'axios-middleware'
Alias for HttpMiddlewareService. Both are the same.
Middleware interface
const myMiddleware = { onRequest(config) { return config; } }
class MyMiddleware extends HttpMiddleware { onRequest(config) {} }
Since v0.3.0, the HttpMiddleware base class was removed. Use a plain object with onRequest/onResponse/onSync methods.

Shows how to create a middleware service, register a middleware with request/response/sync handlers, and use axios normally.

import axios from 'axios'; import { HttpMiddlewareService } from 'axios-middleware'; const service = new HttpMiddlewareService(axios); // Add a middleware that logs requests service.register({ onRequest(config) { console.log('Request:', config.url); return config; }, onResponse(response) { console.log('Response:', response.status); return response; }, onSync(config, req) { // Sync handlers if using an adapter that blocks return config; } }); // Use axios as normal axios.get('/api/data') .then(res => console.log(res.data)) .catch(err => console.error(err));
Debug
Known issues
deprecatedaxios-middleware is deprecated and no longer maintained. The last version (0.4.0) is the end-of-life release.
fix
Migrate to a maintained alternative like axios interceptors or a modern HTTP client library (e.g., ky, got).
affects: >=0.4.0
breakingFrom v0.3.0, the HttpMiddleware base class was removed. Middleware must be plain objects, not class instances.
fix
Change any middleware defined as class MyMiddleware extends HttpMiddleware to a plain object with onRequest/onResponse/onSync methods.
affects: >=0.3.0
breakingIn v0.1.3, handler method names changed: 'handleRequestError' became 'onRequestError', 'handleResponseError' became 'onResponseError'.
fix
Update middleware handlers to use the new 'on' prefix naming convention.
affects: <=0.1.2
Errors
Common errors & fixes
Cannot find module 'axios-middleware'
The package was not installed or is not in node_modules.
fix
Run 'npm install axios-middleware' (ensure axios is also installed as a peer dependency).
Class extends HttpMiddleware is not a constructor
Attempting to use the deprecated HttpMiddleware base class (removed in v0.3.0).
fix
Use a plain object for middleware instead of a class inheriting from HttpMiddleware.
TypeError: Cannot read property 'register' of undefined
The HttpMiddlewareService instance was not created correctly or axios is not passed.
fix
Ensure you instantiate service with: new HttpMiddlewareService(axios).
Upgrade
Version history
0.4.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
15 hits · last 30 days
node
14
OpenAI (training)
1
Resources
ax-middleware — npm install ax-middleware · libregistry