added training report list to client
This commit is contained in:
15
ui/src/api/trainingReport.ts
Normal file
15
ui/src/api/trainingReport.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { CourseEventDetails, CourseEventSummary } from '@shared/types/course'
|
||||
|
||||
//@ts-ignore
|
||||
const addr = import.meta.env.VITE_APIHOST;
|
||||
|
||||
export async function getTrainingReports(): Promise<CourseEventSummary[]> {
|
||||
const res = await fetch(`${addr}/courseEvent`);
|
||||
|
||||
if (res.ok) {
|
||||
return await res.json() as Promise<CourseEventSummary[]>;
|
||||
} else {
|
||||
console.error("Something went wrong");
|
||||
throw new Error("Failed to load training reports");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user