You could use an II(AA)FE to use async-await:
async
await
document.addEventListener('submit', e => { const form = e.target; const statusBusy = form.querySelector('.status-busy'); const statusFailure = form.querySelector('.status-failure'); (async () => { const res = await fetch(form.action, { method: form.method, body: new FormData(form) }) const doc = new DOMParser().parseFromString(await res.text(), 'text/html') const result = document.createElement('div'); result.innerHTML = doc.body.innerHTML; result.tabIndex = -1; form.parentNode.replaceChild(result, form); result.focus(); })().catch(err => { Array.from(form.elements).forEach(field => field.disabled = false); lastActive.focus(); statusBusy.hidden = false; statusFailure.hidden = false; }); // ... });
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
You could use an II(AA)FE to use
async
-await
: