I'm kinda new to javascript and have question about it. Now my practical project is growing a bit bigger. I got the following if else statement. Is it possible to refactor this ? Should i use an use case or are there other options or will this decrease the loading speed of the application.
(function () {
'use strict';
angular
.module('app')
.factory('HttpResponseInterceptor', HttpResponseInterceptor);
HttpResponseInterceptor.$inject = ['$q','$location'];
function HttpResponseInterceptor($q,$location) {
return {
response: function(response){
if (response.status === 401) {
}
return response || $q.when(response);
},
responseError: function(rejection) {
if(rejection.status ===401 && rejection.config.url === "user") {
console.log("Check")
}
else if (rejection.status ===401 && rejection.config.url == "l18n/fr_FR.json")
{
console.log("Check2")
}
else if (rejection.status ===401 && rejection.config.url == "l18n/nl_NL.json")
{
console.log("Check2")
}
else if (rejection.status ===401 && rejection.config.url == "l18n/de_DE.json")
{
console.log("Check2")
}
else if (rejection.status ===401 && rejection.config.url == "l18n/es_ES.json")
{
console.log("Check2")
}
else if (rejection.status ===401 && rejection.config.url == "l18n/en_US.json")
{
console.log("Check2")
}
else
{
$location.path('/login');
}
/* if (rejection.status === 401 && rejection.config.url !== "user") {
$location.path('/login');
}*/
return $q.reject(rejection);
}
};
}
})();