.factory('timestampMarker', ["$rootScope", function () { var timestampMarker = { 'request': function (config) { config.timeout = 15000; return config; } }; return timestampMarker; }]) .config(['$httpProvider',function ( $httpProvider) { //設置調用接口超時 $httpProvider.interceptors.push('timestampMarker'); }]) |
.factory('logTimeTaken', [function () { var logTimeTaken = { request: function (config) { config.requestTimestamp = new Date().getTime(); return config; }, response: function (response) { response.config.responseTimestamp = new Date().getTime(); return response; } }; return logTimeTaken; }]) .config(['$httpProvider',function ( $httpProvider) { $httpProvider.interceptors.push('logTimeTaken'); }]) |