Skip to content

Instantly share code, notes, and snippets.

@stekycz
Created November 29, 2017 17:37
Show Gist options
  • Save stekycz/ee6d7b79bccd962a991afca9e4c941e3 to your computer and use it in GitHub Desktop.
Save stekycz/ee6d7b79bccd962a991afca9e4c941e3 to your computer and use it in GitHub Desktop.
let refreshPromise = null;
const refreshAccessToken = () => {
if (refreshPromise != null) {
return refreshPromise;
}
refreshPromise = sendRefreshTokenRequest();
refreshPromise.then((response) => {
if (response.code !== 200) {
refreshPromise = null;
return false;
}
updateAccessToken(response);
refreshPromise = null;
return true;
});
return refreshPromise;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment