From 51ac57ebf0f305953e4d2bcb4affe437cc632efb Mon Sep 17 00:00:00 2001 From: "eoghan.conlon" Date: Thu, 27 Jul 2023 18:52:11 +0100 Subject: [PATCH] [pass-reset_script] Script now uses a

tag under the form instead of alerts or console to show status of message --- src/PassReset/formHandler.js | 12 ++++++++++-- src/PassReset/index.html | 1 + 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/PassReset/formHandler.js b/src/PassReset/formHandler.js index 75301f9..4e7d271 100644 --- a/src/PassReset/formHandler.js +++ b/src/PassReset/formHandler.js @@ -26,11 +26,19 @@ formEl.addEventListener('submit', () => { fetch('https://reqres.in/api/update', { method: 'POST', body: object - }).then(res => console.log(res)).catch(error => console.log(error)); + }).then(res => { + if(res.status === 200) { + document.getElementById('formStatus').innerHTML = "Success"; + } else if (res.status === 500){ + document.getElementById('formStatus').innerHTML = "Failure"; + } else { + document.getElementById('formStatus').innerHTML = "Failure: Failed to communicate to server"; + } + }).catch(error => document.getElementById('formStatus').innerHTML = "Please try again"); //TODO: Change this to changing a div in html //alert("Success"); } else { //TODO: Change this to changing a div in html - alert("Failure") + document.getElementById('formStatus').innerHTML = "Failure: new passwords don't match"; } }); \ No newline at end of file diff --git a/src/PassReset/index.html b/src/PassReset/index.html index f9d1b0f..9e52a11 100644 --- a/src/PassReset/index.html +++ b/src/PassReset/index.html @@ -16,6 +16,7 @@
+