feat:#60 added switch button (not working)

This commit is contained in:
masterElmar
2023-11-15 04:10:47 +01:00
parent 3e1214d13b
commit 3f1a592468
11 changed files with 242 additions and 96 deletions

View File

@@ -6,7 +6,13 @@ export async function fetchCourse(): Promise<string[]> {
const courses: string[] = [];
await fetch("/api/courses")
.then((response) => {
return response.json();
//check if response type is json
const contentType = response.headers.get("content-type");
if (contentType && contentType.indexOf("application/json") !== -1) {
return response.json();
} else {
return [];
}
})
.then((coursesResponse) => {
coursesResponse.forEach((course: string) => courses.push(course));