From da2e950007be63e3b8b53e0be4e0dbdbc401bb94 Mon Sep 17 00:00:00 2001 From: "eoghan.conlon" Date: Tue, 8 Aug 2023 18:58:05 +0100 Subject: [PATCH] Fetch implemented --- src/recovery.html | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/recovery.html b/src/recovery.html index ac4f399..022f18a 100644 --- a/src/recovery.html +++ b/src/recovery.html @@ -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 = "Success"; + } else if (res.status === 500){ + document.getElementById('formStatus').innerHTML = "Failure"; + } else { + document.getElementById('formStatus').innerHTML = "Failure: Failed to communicate to server"; + } + }).catch(() => { + document.getElementById('formStatus').innerHTML = "Please try again"; + }) } }