Is able to read and delete existing classes, but can not create or update them yet
Need to think of a user-friendly solution to this problem, because currently each student in the class is their own object tied to an account, but if you wanted to add students to a class, you'd be making accounts for them which would require emails and passwords
Here is an example of how the code works: just a basic fetch with the delete method.
fetch(`${url}/api/class_period/delete/${id.slice(6)}`, {
method: 'DELETE',
mode: 'cors', // no-cors, *cors, same-origin
cache: 'no-cache', // *default, no-cache, reload, force-cache, only-if-cached
credentials: 'include', // include, *same-origin, omit
headers: {
"Content-Type": "application/json",
"Authorization": `Bearer ${localStorage.getItem("jwtToken")}`
},
})
.then(response => {
if (!response.ok) {
throw new Error(`HTTP error: ${response.status} ${response.statusText}`);
}
if (response.status === 204) return 'No content'; // Common for DELETE
return response.json();
})
.catch(error => {
console.error('There was a problem with the fetch operation:', error);
});
Plans
restructure/plan how to handle the issue with each student being an object
Functionality
Here is an example of how the code works: just a basic fetch with the delete method.
Plans