Infinite loop in interceptor
I worked on this in my app. Your refresh request needs to include a config/header variable like skipIntercept: true
. Then when you intercept this as a failed response, you can check rejection.config.skipIntercept
variable. If it is true, you go straight to $q.reject(rejection)
.
Where you have:
if (rejection.status == 401) {
Change it to:
if (rejection.status == 401 && !rejection.config.skipIntercept) {
And then above this:
headers : { 'Content-Type' : 'application/x-www-form-urlencoded' },
You need to add:
skipIntercept: true, headers: { 'Content-Type' : 'application/x-www-form-urlencoded' },
PS. there's an existing solution you can use.