A
A
Alexey Yarkov2016-04-21 17:44:58
Angular
Alexey Yarkov, 2016-04-21 17:44:58

Why is angular getting stuck?

Wrote 5 interceptors for intercepting request errors by http codes.

// Перехват сработает в том случае, если сервер ответит кодом 400 (BadRequest)
$httpProvider.interceptors.push('httpBadRequestErrorResponceInterceptor');
// Перехват сработает в том случае, если сервер ответит кодом 401 (Unauthorized)
$httpProvider.interceptors.push('httpUnauthorizedErrorResponceInterceptor');
// Перехват сработает в том случае, если сервер ответит кодом 403 (Forbidden)
$httpProvider.interceptors.push('httpForbiddenErrorResponceInterceptor');
// Перехват сработает в том случае, если сервер ответит кодом 404 (NotFound)
$httpProvider.interceptors.push('httpNotFoundErrorResponceInterceptor');
// Перехват сработает в том случае, если сервер ответит кодом 500 (Internal Server Error)
$httpProvider.interceptors.push('httpInternalServerErrorErrorResponceInterceptor');

I connect all this:
angular
    .module('App', [])
    .config(['$httpProvider',
          function ($httpProvider) {
          /**
           * Подключаем перехват ошибок $http запроса.
           */
          }]);

So, if the server responds with one of these codes, then the request loops and the browser tries to send it again and again quickly quickly))) If you connect them one at a time, then everything works OK.
CHADNT ?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Yarkov, 2016-04-21
@yarkov

I think I understand what's going on! I transferred all the checks to one factory and I connect one interceptor, not 5. That's it, the looping is gone. Something I didn’t google for information that you can’t connect several at once.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question