Forgot Password

Forgot Password

document.getElementById("forgotPasswordForm").addEventListener("submit", async (e) => { e.preventDefault(); const email = document.getElementById("email").value; try { const res = await fetch("/forgot-password", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ email }), }); const data = await res.json(); if (data.success) { Swal.fire({ icon: "success", title: "Email Sent!", text: data.message, confirmButtonColor: "#17a2b8", // matches your teal theme }); } else { Swal.fire({ icon: "error", title: "Oops!", text: data.message, confirmButtonColor: "#17a2b8", }); } } catch (err) { console.error("Request failed:", err); Swal.fire({ icon: "error", title: "Something went wrong", text: "Please try again later.", confirmButtonColor: "#17a2b8", }); } });