@okta-dfuhriman/okta-auth-js
Version:
The Okta Auth SDK
21 lines (20 loc) • 469 B
JavaScript
function poll(url, refresh) {
setTimeout(function () {
fetch(url, {
method: 'POST'
}).then(response => {
if (response.ok) {
return response.json();
} else {
console.error('Poll request failed: ', response.statusText);
}
})
.then(nextStep => {
if (nextStep.poll) {
poll(url, nextStep.poll.refresh);
} else {
window.location.href = nextStep.nextRoute;
}
});
}, refresh);
}