I have a HTTPInterceptor that should go to signin state whenever a 401 is caught. My problem is that I have 3 asynchronous call to API that almost starts the same time. When all of them returns 401, i got an error with the following message:
Transition Rejection($id: 0 type: 6, message: The transition errored, detail: "undefined")
This is my code for my interceptor:
switch (response.status) {
case 401:
let url = $location.absUrl();
// This condition supposed to prevent
// going to signin state again after a response of 401.
// Not really sure if ui-router will navigate still on the same
// state. So maybe this condition is not needed?
if (url.indexOf('sign-in') !== -1) {
deferred.reject(response.data.error);
} else {
if ($transitions._transitionCount === 1) {
$state.go('signin');
}
}
break;
What ive tried so far is to check the transitionCount but still the error persist.
Thanks!
$state.currentand if it's alreadysigninthen don't do$state.go('signin')again? It should work