Registry / testing / axios-debug-log

axios-debug-log

JSON →
library1.0.0jsnpmunverified

Axios interceptor that logs HTTP request and response details using the debug library. Version 1.0.0 supports axios >= 1.0.0, ships TypeScript types, and works in both Node.js and browser environments. The main entry sets up interception and activates logging when the DEBUG environment variable is set to 'axios'. An alternative entry ('axios-debug-log/enable') activates logging immediately without requiring environment variables. Compared to other logging interceptors, it leverages the popular debug library for namespaced, toggleable output and minimal overhead.

npm install axios-debug-log
INSTALL
IMPORT
SIG · AXIOS-DEBUG-LOG
A
axios-debug-log
testingjavascriptv1.0.0
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.

default
import 'axios-debug-log'
import axiosDebugLog from 'axios-debug-log'
The module is a side-effect import; it patches axios globally. Default export is a function for configuration. Use import 'axios-debug-log' to apply defaults, or import setup from 'axios-debug-log' and call setup(options).
addLogger
import { addLogger } from 'axios-debug-log'
const addLogger = require('axios-debug-log').addLogger
ESM named export; CommonJS require works too. addLogger attaches a custom debug logger to a specific axios instance.
enable
import 'axios-debug-log/enable'
import enable from 'axios-debug-log/enable'
This subpath module enables logging immediately without needing DEBUG env var. It is a side-effect import.

Shows side-effect import to enable debug logging for all axios requests/responses, using ENV var or enable subpath.

// 1. Install: npm install axios axios-debug-log // 2. Add import before any axios usage import 'axios-debug-log' // 3. Set environment variable DEBUG=axios before running // Or use the enable path to activate without env var: // import 'axios-debug-log/enable' import axios from 'axios' async function main() { const response = await axios.get('https://api.github.com/') console.log('Done') } main().catch(console.error) // Run: DEBUG=axios node index.js
Debug
Known issues
gotchaThe default import ('axios-debug-log') only sets up interception; logging is inactive until DEBUG env var is set to 'axios' (or localStorage.debug in browser). If you forget to set DEBUG, no output appears.
fix
Set environment variable DEBUG=axios before running your app, or use import 'axios-debug-log/enable' to activate logging immediately.
affects: >=1.0.0
gotchaThe module globally mutates axios by adding interceptors. If you have multiple axios instances, only the default instance is patched by the default import. Use addLogger for custom instances.
fix
Use addLogger(instance, debugLogger) to attach logging to specific axios instances.
affects: >=1.0.0
gotchaThe enable subpath ('axios-debug-log/enable') is a separate entry point; it does not export anything and must be imported as a side-effect.
fix
Import with: import 'axios-debug-log/enable' (not import { enable } from ...)
affects: >=1.0.0
Errors
Common errors & fixes
Error: Cannot find module 'axios-debug-log/enable'
Trying to import a subpath that may not be resolved if package.json 'exports' field is missing or not supported.
fix
Ensure you are using a module bundler or Node.js version that supports package.json 'exports'. Alternatively, use the main entry: require('axios-debug-log') and set DEBUG env var.
TypeError: addLogger is not a function
Attempting to call addLogger after importing 'axios-debug-log' without named import.
fix
Use named import: import { addLogger } from 'axios-debug-log'.
Upgrade
Version history
1.0.0latest on npm
Audit
Dependencies
axiosrequiredpeer dependency required to intercept requests
debugrequiredruntime dependency for logging
Agent activity
19 hits · last 30 days
node
18
OpenAI (training)
1
Resources
axios-debug-log — npm install axios-debug-log · libregistry