Created
September 24, 2020 18:16
-
-
Save sinnus/6be8a4b0a142191a1cabd7f38274ca62 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
function apiReq(url) { | |
getToken() | |
.then(function(token) { | |
axios.get(url, {headers: {'Authorization' : 'Bearer ' + token}}) | |
.then(function(response) { | |
alert(response.data); | |
}); | |
}) | |
} | |
function getToken() { | |
return new Promise(function(resolve, reject) { | |
keycloak.updateToken(5) | |
.then(function() { | |
resolve(keycloak.token); | |
}) | |
.catch(function() { | |
alert('Failed to refresh token'); | |
}) | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment