Last active
November 29, 2017 17:34
-
-
Save stekycz/9e0e15419e0f508cfa40ccdaa36a5547 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const refreshAccessToken = async () => { | |
const response = await sendRefreshTokenRequest(); | |
if (response.code !== 200) { | |
return false; | |
} | |
updateAccessToken(response); | |
return true; | |
}; | |
let response = await sendAuthorizedRequest(); | |
if (response.code === 401) { | |
const refreshed = await refreshAccessToken(); | |
if (!refreshed) { | |
logout(); | |
} | |
response = await sendAuthorizedRequest(); | |
if (response.code === 401) { | |
logout(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment