eeg_certs/frontend/src/utils/allCourses.ts

13 lines
354 B
TypeScript
Raw Normal View History

2023-08-25 22:54:30 +00:00
import { createSignal } from "solid-js";
import { Course } from "../types/Course";
export const [allCourses, setAllCourses] = createSignal<Array<Course>>([]);
(() => {
// Get all courses from the API
fetch(`${import.meta.env.VITE_BACKEND_URL}/api/course`)
.then((res) => res.json())
.then((data) => setAllCourses(data));
})();