[pass-reset_script] Removing TODOs re. alerts, adding todo to change the url in the post and code in check

This commit is contained in:
eoghan.conlon 2023-07-27 18:55:33 +01:00
parent 51ac57ebf0
commit 6d50144248

View file

@ -23,11 +23,13 @@ formEl.addEventListener('submit', () => {
formData.append("field", "password"); formData.append("field", "password");
formData.append("value", newPW); formData.append("value", newPW);
const object = Object.fromEntries(formData.entries()); const object = Object.fromEntries(formData.entries());
//TODO: Change this to use our api
fetch('https://reqres.in/api/update', { fetch('https://reqres.in/api/update', {
method: 'POST', method: 'POST',
body: object body: object
}).then(res => { }).then(res => {
if(res.status === 200) { //TODO: Change success to use 200 rather than 201 (This is the code that the api testing service uses for the chosen api)
if(res.status === 201) {
document.getElementById('formStatus').innerHTML = "<span style='background-color: green; color: white'>Success</span>"; document.getElementById('formStatus').innerHTML = "<span style='background-color: green; color: white'>Success</span>";
} else if (res.status === 500){ } else if (res.status === 500){
document.getElementById('formStatus').innerHTML = "<span style='background-color: red; color: white'>Failure</span>"; document.getElementById('formStatus').innerHTML = "<span style='background-color: red; color: white'>Failure</span>";
@ -35,10 +37,7 @@ formEl.addEventListener('submit', () => {
document.getElementById('formStatus').innerHTML = "<span style='background-color: red; color: white'>Failure: Failed to communicate to server</span>"; document.getElementById('formStatus').innerHTML = "<span style='background-color: red; color: white'>Failure: Failed to communicate to server</span>";
} }
}).catch(error => document.getElementById('formStatus').innerHTML = "<span style='background-color: yellow; color: black'>Please try again</span>"); }).catch(error => document.getElementById('formStatus').innerHTML = "<span style='background-color: yellow; color: black'>Please try again</span>");
//TODO: Change this to changing a div in html
//alert("Success");
} else { } else {
//TODO: Change this to changing a div in html
document.getElementById('formStatus').innerHTML = "<span style='background-color: red; color: white'>Failure: new passwords don't match</span>"; document.getElementById('formStatus').innerHTML = "<span style='background-color: red; color: white'>Failure: new passwords don't match</span>";
} }
}); });