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);
}
function GetActiveClasses() {
let func = fetch(`${location.origin}/seqta/student/load/subjects?`, {
method: 'POST',
headers: {
'Content-Type': 'application/json; charset=utf-8',
},
body: JSON.stringify({}),
});
async function GetActiveClasses() {
try {
const response = await fetch(`${location.origin}/seqta/student/load/subjects?`, {
method: 'POST',
headers: { 'Content-Type': 'application/json; charset=utf-8' },
body: JSON.stringify({})
});
return func
.then((result) => result.json())
.then((response) => response.payload);
if (!response.ok) {
throw new Error(`HTTP error! Status: ${response.status}`);
}
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) {