Registry / devops / axios-time

axios-time

JSON →
library1.0.0jsnpmunverified

Lightweight plugin for axios that adds timing data (start/end timestamps and elapsed time) to every HTTP request response. Version 1.0.0, stable and unmaintained since 2020. No longer actively developed; alternative is to use axios built-in request/response interceptors or libraries like axios-timelog. Works only with axios instances or globally patched axios.

npm install axios-time
INSTALL
IMPORT
SIG · AXIOS-TIME
A
axios-time
devopsjavascriptv1.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
const axiosTime = require('axios-time');
import axiosTime from 'axios-time';
Package only provides CJS exports - no ESM or TypeScript types.
axiosTime (function)
const axiosTime = require('axios-time'); axiosTime(axios);
axiosTime() without passing axios instance; or passing a non-axios object.
The function mutates the axios instance passed; expect `response.timings` after a request.
response.timings
const response = await axios.get('/'); console.log(response.timings.elapsedTime);
console.log(response.timing); or response.timings.elapsedTime incorrectly cased.
timings is only added if axiosTime(axios) was called before the request.

Demonstrates the plugin's usage: require both axios and axios-time, call axiosTime(axios) once, then make a request and access response.timings.

const axios = require('axios'); const axiosTime = require('axios-time'); axiosTime(axios); async function fetchUser() { try { const response = await axios.get('https://jsonplaceholder.typicode.com/users/1'); console.log('Timings:', response.timings); // e.g., { timingEnd: 1599035291441, timingStart: 1599035289182, elapsedTime: 2259 } } catch (err) { console.error(err); } } fetchUser();
Debug
Known issues
deprecatedPackage not updated since 2020; no TypeScript definitions, no ESM support.
fix
Consider implementing your own timing via axios interceptors or use a maintained alternative.
affects: >=1.0.0
gotchaaxiosTime mutates the passed axios instance globally. If you use separate instances, you must call axiosTime on each one.
fix
Create separate axios instances with `axios.create()` and apply the plugin to each as needed.
affects: >=1.0.0
gotcharesponse.timings is only present on successful responses (resolved promise). Axios errors (rejected promise) do not contain timings.
fix
Handle success and error separately or wrap in try-catch to inspect err.response?.timings.
affects: >=1.0.0
gotchaelapsedTime is in milliseconds but is a number (not a high-resolution duration). Works poorly in Node.js with precision below 1ms.
fix
Use process.hrtime.bigint() for high-precision custom timing instead.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: axiosTime is not a function
Importing the package incorrectly (e.g., using ES6 import with default export).
fix
Use `const axiosTime = require('axios-time');` instead of `import axiosTime from 'axios-time';`
Cannot read property 'timings' of undefined
Attempting to access response.timings from an error object (rejected promise).
fix
Access timings only on successful responses or use `err.response?.timings` in the catch block.
response.timings is undefined
Forgot to call axiosTime(axios) before making requests.
fix
Call `axiosTime(axios);` at the start of your application, passing the same axios instance you use.
Upgrade
Version history
1.0.0latest on npm
Audit
Dependencies
axiosrequiredpeer dependency - the plugin patches an axios instance
Agent activity
9 hits · last 30 days
node
8
OpenAI (training)
1
Resources
axios-time — npm install axios-time · libregistry