[O] Optimize loadCourses request

This commit is contained in:
Hykilpikonna
2019-09-07 14:04:38 -04:00
parent 393fc1cc71
commit a7384753c8
+14 -25
View File
@@ -93,34 +93,23 @@ export default class App extends Vue
*/
public loadCoursesAfterLogin()
{
// Fetch request
fetch(`${Constants.API_URL}/courses`,
{method: 'POST', body: JSON.stringify({token: this.token})})
.then(res =>
this.http.post('/courses', {}).then(response =>
{
// Get response body text
res.text().then(text =>
// Check success
if (response.success)
{
// Parse response
let response = JSON.parse(text);
// Save courses
this.courses = response.data;
// Check success
if (response.success)
{
// Save courses
this.courses = response.data;
// Load assignments
this.loadAssignments();
}
else
{
// Show error message TODO: Show it properly
alert(response.data);
}
})
})
.catch(alert)
// Load assignments
this.loadAssignments();
}
else
{
// Show error message TODO: Show it properly
alert(response.data);
}
});
}
/**