title: Delegating/ Decorating $http.get in angular
body: <p>Following page have an example for delegating debug function of $log in angular. </p>
  
  <p><a href="http://solutionoptimist.com/2013/10/07/enhance-angularjs-logging-using-decorators/" rel="nofollow">http://solutionoptimist.com/2013/10/07/enhance-angularjs-logging-using-decorators/</a></p>
  
  <p>Similarly I would Like to delegate get/post functions of $http Service. So that I can log all the request that my app does.</p>
  
  <p>Below is my code</p>
  
  <pre><code> $provide.decorator('$http', ["$delegate", function($delegate) {
    var debugFn = $delegate.get;
    $delegate.get = function() {
      var args = [].slice.call(arguments);
  
      // Prepend timestamp
      console.log(args[0]);
  
      // Call the original with the output prepended with formatted timestamp
      debugFn.apply(null, args)
    };
  
    return $delegate;
  }]);
  </code></pre>
  
  <p>even though it is logging the url it throws an exception after that</p>
  
  <pre><code>TypeError: Cannot read property 'finally' of undefined
  at handleRequestFn (angular.js:17382)
  at compileTemplateUrl (angular.js:8270)
  at applyDirectivesToNode (angular.js:7885)
  at compileNodes (angular.js:7431)
  at compile (angular.js:7338)
  at applyDirectivesToNode (angular.js:7808)
  at compileNodes (angular.js:7431)
  at compileNodes (angular.js:7443)
  at compile (angular.js:7338)
  at angular.js:1630
  </code></pre>
  
  <p>what am i missing?</p>