[O] Optimize loadAssignments()
This commit is contained in:
+15
-26
@@ -109,7 +109,8 @@ export default class App extends Vue
|
|||||||
// Show error message TODO: Show it properly
|
// Show error message TODO: Show it properly
|
||||||
alert(response.data);
|
alert(response.data);
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
|
.catch(alert);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -123,34 +124,22 @@ export default class App extends Vue
|
|||||||
this.courses.forEach(course =>
|
this.courses.forEach(course =>
|
||||||
{
|
{
|
||||||
// Send request to get assignments
|
// Send request to get assignments
|
||||||
fetch(`${Constants.API_URL}/assignments`,
|
this.http.post('/assignments', {id: course.assignmentsId}).then(response =>
|
||||||
{method: 'POST', body: JSON.stringify({token: this.token, id: course.assignmentsId})})
|
|
||||||
.then(res =>
|
|
||||||
{
|
{
|
||||||
// Get response body text
|
// Check success
|
||||||
res.text().then(text =>
|
if (response.success)
|
||||||
{
|
{
|
||||||
// Parse response
|
// Load assignments
|
||||||
let response = JSON.parse(text);
|
// Parse json and filter it
|
||||||
|
course.assignments = JsonUtils.filterAssignments(response.data);
|
||||||
// Check success
|
}
|
||||||
if (response.success)
|
else
|
||||||
{
|
{
|
||||||
// Load assignments
|
// Show error message TODO: Show it properly
|
||||||
// Parse json and filter it
|
alert(response.data);
|
||||||
course.assignments = JsonUtils.filterAssignments(response.data);
|
}
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Show error message TODO: Show it properly
|
|
||||||
alert(response.data);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
.catch(err =>
|
.catch(alert);
|
||||||
{
|
|
||||||
alert(err);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Wait for assignments to be ready.
|
// Wait for assignments to be ready.
|
||||||
|
|||||||
Reference in New Issue
Block a user