Skip to content

Instantly share code, notes, and snippets.

@stekycz
Last active November 29, 2017 17:34
Show Gist options
  • Save stekycz/9e0e15419e0f508cfa40ccdaa36a5547 to your computer and use it in GitHub Desktop.
Save stekycz/9e0e15419e0f508cfa40ccdaa36a5547 to your computer and use it in GitHub Desktop.
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