Created
February 13, 2017 19:10
-
-
Save AlexFrazer/d8078cb3bfb1bfb565f2bd45893b306b to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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