Sam
Sam

Reputation: 15770

AngularJS HTTP Interceptors

I was wondering if HTTP Interceptors in AngularJS cause a performance hit?

I want to intercept requests and prepend the absolute URL:

angular.module('app').config(['$httpProvider', function ($httpProvider) {
    $httpProvider.interceptors.push(function () {
        return {
            request: function (config) {
                config.url = 'http://localhost:9060/' + config.url;
            }
        };
     });

}]);

Upvotes: 1

Views: 968

Answers (1)

Daniel Tabuenca
Daniel Tabuenca

Reputation: 13681

Unless you do something crazy and time-consuming within your interceptor, the actual invocation of the interceptor will be absolutely negligible in your application as compared to anything else.

Upvotes: 4

Related Questions