section.ts 880 Bytes
Newer Older
Zac Wood's avatar
Zac Wood committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
export default interface Section {
    id: number;
    name: string;
    title: string;
    crn: string;
    instructor: string;
    location: string;
    days: string;
    startTime: string;
    endTime: string;
}

export async function fetchSectionsWithCRN(crn: string): Promise<Section[]> {
    const response = await fetch('http://localhost:3001/api/courses/1/sections');
    const jsonObjects = await response.json();
    let sections: Section[] = [];
    jsonObjects.forEach((object: any) => {
        sections.push({
            id: object.id,
            name: object.name,
            title: object.title,
            crn: object.crn,
            instructor: object.instructor,
            location: object.location,
            days: object.days,
            startTime: object.start_time,
            endTime: object.end_time,
        });
    });
    return sections;
}