You can use httpInterceptor for this (the official $ http documentation contains additional information)
// register the interceptor as a service $provide.factory('xdebugInterceptor', function($q) { return { // optional method 'request': function(config) { // do something on success // !!! adjust the config object // add request param XDEBUG_SESSION_START=PHPSTORM // it will be added to every made request config.params = config.params || {}; config.params.XDEBUG_SESSION_START: "PHPSTORM"; return config; }, // optional method 'requestError': function(rejection) { // do something on error return $q.reject(rejection); }, // optional method 'response': function(response) { // do something on success return response; }, // optional method 'responseError': function(rejection) { // do something on error return $q.reject(rejection); } }; }); // make this conditional so you use it only in DEV mode $httpProvider.interceptors.push('xdebugInterceptor');
source share