Is it possible to prevent a request using angularjs interceptors ?
$provide.factory(\'myHttpInterceptor\', function($q, someService) {
return {
\'reque
In 1.1.5 and later you can use the 'timeout' property of the configuration object.
From the documentation:
timeout – {number|Promise} – timeout in milliseconds, or promise that should abort the request when resolved.
Simple example:
$provide.factory('myHttpInterceptor', function($q, someService) {
return {
'request': function(config) {
var canceler = $q.defer();
config.timeout = canceler.promise;
if (true) {
// Canceling request
canceler.resolve();
}
return config;
}
}
});
$httpProvider.interceptors.push('myHttpInterceptor');