timeout超时响应
.factory('timestampMarker', ["$rootScope", function () {
var timestampMarker = {
'request': function (config) {
config.timeout = 15000;
return config;
}
};
return timestampMarker;
}])
.config(['$httpProvider',function ( $httpProvider) {
//设置调用接口超时
$httpProvider.interceptors.push('timestampMarker');
}]) |
设置request和response
.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');
}]) |
转载于:https://www.cnblogs.com/maoyazhi/p/8989125.html