Skip to content

Instantly share code, notes, and snippets.

@AlexFrazer
Created February 13, 2017 19:10
Show Gist options
  • Save AlexFrazer/d8078cb3bfb1bfb565f2bd45893b306b to your computer and use it in GitHub Desktop.
Save AlexFrazer/d8078cb3bfb1bfb565f2bd45893b306b to your computer and use it in GitHub Desktop.
async function request(...args) {
try {
await makeRequest(...args);
} catch (e) {
await getRefreshToken();
// try to re-request the previous asset
}
}
async function getRefreshToken() {
try {
await makeRequest('/auth/refresh-token');
} catch (e) {
await getRememberMeToken();
}
}
async function getRememberMeToken() {
try {
await makeRequest('/auth/remember-me');
} catch (e) {
redirect('/login');
// after they login, retry the method.
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment