{"action":"created","issue":{"url":"https://api.github.com/repos/mzabriskie/axios/issues/266","repository_url":"https://api.github.com/repos/mzabriskie/axios","labels_url":"https://api.github.com/repos/mzabriskie/axios/issues/266/labels{/name}","comments_url":"https://api.github.com/repos/mzabriskie/axios/issues/266/comments","events_url":"https://api.github.com/repos/mzabriskie/axios/issues/266/events","html_url":"https://github.com/mzabriskie/axios/issues/266","id":140798511,"number":266,"title":"Interceptors - how to prevent intercepted messages from resolving as error","user":{"login":"dmt0","id":2717746,"avatar_url":"https://avatars.githubusercontent.com/u/2717746?v=3","gravatar_id":"","url":"https://api.github.com/users/dmt0","html_url":"https://github.com/dmt0","followers_url":"https://api.github.com/users/dmt0/followers","following_url":"https://api.github.com/users/dmt0/following{/other_user}","gists_url":"https://api.github.com/users/dmt0/gists{/gist_id}","starred_url":"https://api.github.com/users/dmt0/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dmt0/subscriptions","organizations_url":"https://api.github.com/users/dmt0/orgs","repos_url":"https://api.github.com/users/dmt0/repos","events_url":"https://api.github.com/users/dmt0/events{/privacy}","received_events_url":"https://api.github.com/users/dmt0/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/mzabriskie/axios/labels/question","name":"question","color":"cc317c"}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2016-03-14T21:09:11Z","updated_at":"2016-07-29T19:01:28Z","closed_at":"2016-07-16T17:45:39Z","body":"I'm trying to make an interceptor for 401 responses that result from expired token. Upon interception I want to login and retry the requests with the new token. My problem is that login is also done asynchronously, so by the time the retry happens, the original promises reject. Is there a way around that? Here's my code:\r\n\r\n    axios.interceptors.response.use(undefined, err => {\r\n      if (err.status === 401 && err.config && !err.config.__isRetryRequest) {\r\n        refreshLogin(getRefreshToken(),\r\n          success => {\r\n            setTokens(success.access_token, success.refresh_token)\r\n            err.config.__isRetryRequest = true\r\n            err.config.headers.Authorization = 'Bearer ' + getAccessToken()\r\n            axios(err.config)\r\n          },\r\n          error => { console.log('Refresh login error: ', error) }\r\n        )\r\n      }\r\n    })"},"comment":{"url":"https://api.github.com/repos/mzabriskie/axios/issues/comments/236266121","html_url":"https://github.com/mzabriskie/axios/issues/266#issuecomment-236266121","issue_url":"https://api.github.com/repos/mzabriskie/axios/issues/266","id":236266121,"user":{"login":"heeton","id":7713,"avatar_url":"https://avatars.githubusercontent.com/u/7713?v=3","gravatar_id":"","url":"https://api.github.com/users/heeton","html_url":"https://github.com/heeton","followers_url":"https://api.github.com/users/heeton/followers","following_url":"https://api.github.com/users/heeton/following{/other_user}","gists_url":"https://api.github.com/users/heeton/gists{/gist_id}","starred_url":"https://api.github.com/users/heeton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/heeton/subscriptions","organizations_url":"https://api.github.com/users/heeton/orgs","repos_url":"https://api.github.com/users/heeton/repos","events_url":"https://api.github.com/users/heeton/events{/privacy}","received_events_url":"https://api.github.com/users/heeton/received_events","type":"User","site_admin":false},"created_at":"2016-07-29T19:01:28Z","updated_at":"2016-07-29T19:01:28Z","body":"@dmt0 Did you get this working? "}}
{"actor":{"display_login":"heeton"}}