REGISTER_ERROR error=expired_code

Hi,

I’m trying to redirect user to registration page through js script after an API call to internal API like this :

            <button type="button" class="mdc-button mdc-button--raised" onclick="createAccount()">
                ${msg("createAccount")}
            </button>
        </div>
    </form>
</div>
<script>

   function createAccount(url) {
        console.log("create!");
fetch('http://..../auth/realms/WEB/hello?customer_code=dede&zip_code=dedededzd').then(function (response) {
if (response.status !== 200) {
console.log('error')
return
}
response.text().then(function (data) {
console.log(data);
}
);
console.log('OK');
location.href=${url.registrationUrl};
})
        console.log("create!")
 }

But I’m getting REGISTER_ERROR, error=expired_code, the only way i can redirect correctly to registration page for now is by doing the location.href on the onclick button’s attribute.

Thanks,

Dan

1 Like