You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It would be nice to have a metadata block returned in the response that would include a response time in milliseconds. I find myself having to write a small wrapper around axios to time any requests I make (for metric collection). Would this be a valid candidate for axios?
Reacted by Shawn D'Souza, Megan K, Jules Hablot, Justin Litchfield, Rafael Lüder, Jan Míšek, Emanuel Quimper, Roger V, James, Clarkie and 72 more
Reacted by Gilles De Mey, Lucas Bento, dev101, christoth, Gerard Brull, Serhat Ates, Cedric TESNIERE, Hendry Sadrak, Tejas Parab, thisisashwani and 4 more
This could be written as a plugin. Something like:
functionaxiosTiming(axiosInstance){// Store request timestamp in `config`axiosInstance.interceptors.request.add(...);// Store response timestamp and/or response time in response/error `config`axiosInstance.interceptors.response.add(...);}
I'm not sure this feature is common enough to add it to the core (although it'd be relatively easy to implement and wouldn't have a performance penalty for those not using it).
IMO, this would be great for debugging requests, more so on hybrid apps with less than ideal debugging environments. It would be a good addition to an already must-have like axios!
Using the interceptors would provide a timing including the request and the parsing. That would be interesting to have a precise timing for the request itself.
Reacted by dev101, dermansi, Peter, Stanislav Goncharov, akhrabrov, Tejas Parab and Eamonn Keogh
This would be a very useful feature, e.g. for instrumenting and monitoring 3rd party API performance.
Ideally, to be compatible with request timing schema:
Reacted by dev101, Roger V, Jaydeep Solanki, Sagiv Frankel, Lucas Fiege, Demi, John Tran, Anil V, Ievgenii Krevenets, christoth and 75 more
Reacted by dev101, Anil V, Ievgenii Krevenets, christoth, Paweł Szymański, Robin, Gajus Kuizinas, Gerard Brull, Antério Vieira, Valentin Hervieu and 20 more
Reacted by Rigo B Castro, Kai Curry, Davi Vilela de Araújo, Chao Y, Tiago Nápoli, johnnie munger, Ayyappa, Rahul Patel, Tzach, thisisashwani and 3 more
Reacted by image72, Aleksei Minin, Peter Motykowski, Stanislav Goncharov, James, Rob Herley, Nishchit Dhanani, Hendry Sadrak, Ryan Parker, Tejas Parab and 3 more
I tried axios-timing.js but looking under the hood it basically uses interceptors.
The problem with interceptors are they are called before the 'socket' event gets triggered on the http object (probably for good reason i suppose...).
This means if you start the timer using interceptors you are combining both "queuing" time and time actually going out of the door.
However this matters in the use-case when you have maxed out your sockets, but a person wants to report queuing time separate from request time.
Reacted by Vitaly Orlov, liyuanqiu, Wayne W.J. Chen, Maxim Lavrinenko, sachitram-cv, Stanislav Goncharov, Roger V, Anthony Bryle Poncio, Devin Leaman, Marc and 15 more
In my use case, a large blob is sent to a third-party service and processed before a response is sent. I would like to measure the time between finishing sending the data and the response. This would allow me to differentiate between slow upload (which may be down to network congestion) and slow processing.
Activity
rubennorte commentedon Feb 12, 2017
This could be written as a plugin. Something like:
I'm not sure this feature is common enough to add it to the core (although it'd be relatively easy to implement and wouldn't have a performance penalty for those not using it).
@mzabriskie, @nickuraltsev, thoughts?
rgrvlsk commentedon Sep 4, 2017
IMO, this would be great for debugging requests, more so on hybrid apps with less than ideal debugging environments. It would be a good addition to an already must-have like axios!
Cheers.
HamsterCoder commentedon Feb 1, 2018
Hi, I am trying to implement this myself with the proposed approach with interceptors, but there are a few things I cannot figure out:
I am not sure whether I can add random stuff to config (will it break axios, is there a right place for metadata), e.g:
testerez commentedon Mar 16, 2018
Using the interceptors would provide a timing including the request and the parsing. That would be interesting to have a precise timing for the request itself.
dev101 commentedon Mar 23, 2018
This would be a very useful feature, e.g. for instrumenting and monitoring 3rd party API performance.
Ideally, to be compatible with

requesttiming schema:Mouvedia commentedon Jul 9, 2018
You would end up with this subset:
forivall commentedon Jul 10, 2018
Proof of concept for node, as a plugin / interceptors: https://gist.github.com/forivall/cbd363792b5e09c8aa4e8cb5390f8d93
hooks would need to be added for XHR timings.
pmotyka commentedon Mar 7, 2019
@forivall, thanks for providing this POC code!
Here's some rough steps on how I was able to use it:
Download and unpack .zip of cbd363792b5e09c8aa4e8cb5390f8d93 gist
npm install -g typscript
npm install -D @types/node axios
tsc *.ts
Copy resulting axios-timing.js into your project
const addAxiosTiming = require('./axios-timing').addAxiosTiming;
addAxiosTiming(axiosInstance);
timings data will be available on the response
AdeOpe commentedon May 6, 2019
I tried axios-timing.js but looking under the hood it basically uses interceptors.
The problem with interceptors are they are called before the 'socket' event gets triggered on the http object (probably for good reason i suppose...).
This means if you start the timer using interceptors you are combining both "queuing" time and time actually going out of the door.
However this matters in the use-case when you have maxed out your sockets, but a person wants to report queuing time separate from request time.
100% I agree with @dev101 suggestion.
numandev1 commentedon Jun 15, 2020
here is the demo https://stackoverflow.com/a/62257712/8079868
jasonsaayman commentedon May 14, 2021
Closing this issue as I don't think it will be added to the axios core. If you disagree please re-open
fguille94 commentedon Mar 29, 2022
I disagree, this should be added to the core
MatthiasKunnen commentedon Mar 16, 2023
In my use case, a large blob is sent to a third-party service and processed before a response is sent. I would like to measure the time between finishing sending the data and the response. This would allow me to differentiate between slow upload (which may be down to network congestion) and slow processing.
smff commentedon Jun 27, 2023
so? any updates here ... becauce any solution based on interseptors gives wrong data in browser(((
andreluiz901 commentedon Nov 21, 2024
Please reopen this and make this as a built0in feature. I am changing now axios to other lib at one of my services just because of this feature.
jasonsaayman commentedon Jul 30, 2025
closing see #6984