UNPKG

@okta-dfuhriman/okta-auth-js

Version:
21 lines (20 loc) 469 B
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); }