refactor getavailableclasses function

This commit is contained in:
SethBurkart123
2023-11-17 15:55:08 +11:00
parent 5e4e1b0e17
commit 426f7ff16f
+16 -11
View File
@@ -1698,18 +1698,23 @@ function GetUpcomingAssessments() {
.then((response) => response.payload); .then((response) => response.payload);
} }
function GetActiveClasses() { async function GetActiveClasses() {
let func = fetch(`${location.origin}/seqta/student/load/subjects?`, { try {
method: 'POST', const response = await fetch(`${location.origin}/seqta/student/load/subjects?`, {
headers: { method: 'POST',
'Content-Type': 'application/json; charset=utf-8', headers: { 'Content-Type': 'application/json; charset=utf-8' },
}, body: JSON.stringify({})
body: JSON.stringify({}), });
});
return func if (!response.ok) {
.then((result) => result.json()) throw new Error(`HTTP error! Status: ${response.status}`);
.then((response) => response.payload); }
const data = await response.json();
return data.payload;
} catch (error) {
console.error('Oops! There was a problem fetching active classes:', error);
}
} }
function comparedate(obj1, obj2) { function comparedate(obj1, obj2) {