GetDataBorrow(); async function GetDataBorrow() { try { const res = await fetch("/GetDataBorrow"); if (res.ok) { const data = await res.json(); console.log(data); let output = ""; data.resu.forEach((e) => { // Display only records with statusborrow equal to 2 (Approve) if (e.statusborrow === 2) { output += ` ${e.email} ${e.name} ${new Date(e.borrowdate).toLocaleDateString()} - ${new Date( e.returndate ).toLocaleDateString()}
${ e.statusborrow == 1 ? "waiting" : e.statusborrow == 2 ? "Approve" : "Disapprove" }
`; } }); document.querySelector("table").innerHTML += output; } } catch (err) { alert(err); } } document.getElementById("lechome").addEventListener("click", function (event) { event.preventDefault(); // Prevent the default link behavior window.location.href = "/lecturerHomepage"; }); document.getElementById("lecass").addEventListener("click", function (event) { event.preventDefault(); // Prevent the default link behavior window.location.href = "/lecAss"; }); document.getElementById("lecre").addEventListener("click", function (event) { event.preventDefault(); // Prevent the default link behavior window.location.href = "/lecRe"; }); document.getElementById("lechis").addEventListener("click", function (event) { event.preventDefault(); // Prevent the default link behavior window.location.href = "/lecHis"; }); document.getElementById("rolepage").addEventListener("click", function (event) { event.preventDefault(); // Prevent the default link behavior window.location.href = "/rolePage"; });