SHARE
TWEET

Untitled

a guest Aug 22nd, 2019 77 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // axios.interceptors.request.use(request => {
  2. //   logger.info('Starting Request', request);
  3. //   return request;
  4. // });
  5. axios.interceptors.request.use(
  6.   function(config) {
  7.     config.metadata = { startTime: new Date() };
  8.     return config;
  9.   },
  10.   function(error) {
  11.     return Promise.reject(error);
  12.   }
  13. );
  14. axios.interceptors.response.use(
  15.   function(response) {
  16.     response.config.metadata.endTime = new Date();
  17.     response.duration = response.config.metadata.endTime - response.config.metadata.startTime;
  18.     return response;
  19.   },
  20.   function(error) {
  21.     error.config.metadata.endTime = new Date();
  22.     error.duration = error.config.metadata.endTime - error.config.metadata.startTime;
  23.     return Promise.reject(error);
  24.   }
  25. );
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top