[+] Check the success flag in response

This commit is contained in:
Hykilpikonna
2019-09-07 08:28:54 -04:00
parent c7d16a00e6
commit 805ffaa50e
+14 -2
View File
@@ -31,8 +31,20 @@ export default class Login extends Vue
// Get response body text
res.text().then(text =>
{
// Call custom event with courses info
this.$emit('login:courses', JSON.parse(text));
// Parse response
let response = JSON.parse(text);
// Check success
if (response.success)
{
// Call custom event with courses info
this.$emit('login:token', response.token);
}
else
{
// Allow the user to retry
this.loading = false;
}
})
})
.catch(err =>