Zakaria Ali Osman
Zakaria Ali Osman

Reputation: 17

How can i Cancel the before request send restangular

this Code is not Canceling the request, why?

RestangularConfigurer.addFullRequestInterceptor(function (element, operation, route, url, headers, params, httpConfig) {
    var defer = $q.defer();
    defer.reject();
    httpConfig.timeout = defer;
    return {
        element: element,
        headers: headers,
        params: params,
        httpConfig: httpConfig
    };
});

Upvotes: 1

Views: 949

Answers (1)

Ilan Frumer
Ilan Frumer

Reputation: 32377

You should assign a promise to timeout:

httpConfig.timeout = defer.promise;

And resolve it (not reject):

defer.resolve();

Upvotes: 1

Related Questions