From ca4922343295deaddd565ea08a1d28b343da6a31 Mon Sep 17 00:00:00 2001 From: Hykilpikonna Date: Sat, 24 Aug 2019 21:05:23 +0800 Subject: [PATCH] [+] Get assignments for all the courses --- src/components/app/app.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/components/app/app.ts b/src/components/app/app.ts index 6f22074..475b149 100644 --- a/src/components/app/app.ts +++ b/src/components/app/app.ts @@ -3,6 +3,7 @@ import Login from '@/components/login/login'; import Navigation from '@/components/navigation/navigation'; import Overall from '@/pages/overall/overall'; import Constants from '@/constants'; +import JsonUtils from '@/utils/json-utils'; /** * Objects of this interface represent assignment grades. @@ -59,6 +60,25 @@ export default class App extends Vue // Debug output TODO: Remove this console.log(courses); + + // Get assignments for all the courses + this.courses.forEach(course => + { + // Send request to get assignments + fetch(`${Constants.API_URL}/veracross/assignments?id=${course.assignmentsId}`).then(res => + { + // Get response body text + res.text().then(text => + { + // Parse json and filter it + course.assignments = JsonUtils.filterAssignments(JSON.parse(text)); + }) + }) + .catch(err => + { + alert(err); + }); + }); } /**