Fetch implemented

This commit is contained in:
eoghan.conlon 2023-08-08 18:58:05 +01:00
parent 62c0767e78
commit da2e950007

View file

@ -38,7 +38,21 @@
} else {
object = { user: value };
}
alert(JSON.stringify(object));
fetch('https://api.account.skynet.ie/ldap/recover/password', {
method: 'POST',
body: JSON.stringify(object),
mode: "cors"
}).then(res => {
if(res.status === 200){
document.getElementById('formStatus').innerHTML = "<span style='background-color: green; color: white'>Success</span>";
} else if (res.status === 500){
document.getElementById('formStatus').innerHTML = "<span style='background-color: red; color: white'>Failure</span>";
} else {
document.getElementById('formStatus').innerHTML = "<span style='background-color: red; color: white'>Failure: Failed to communicate to server</span>";
}
}).catch(() => {
document.getElementById('formStatus').innerHTML = "<span style='background-color: yellow; color: black'>Please try again</span>";
})
}
}