-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: add student service #147
Conversation
|
||
axios.get(endpoint).then(response => { | ||
student.value = Student.fromJSON(response.data); | ||
}).catch(error => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now we just discard errors, but there are several cases where we should handle these errors:
- Network disconnects
- Authorization errors
- Not found errors
- Other errors (custom validation errors, server errors)
One way to handle these is to define a new variable const errors = ref(null)
and set its value when we catch an error. Components that use the composable services can watch this variable to display meaningful messages in case of an error.
We can also use PrimeVue's ToastService
to automatically display a toast in the top right corner with the error messages (https://primevue.org/toast/).
Another thing: all data services will probably use the same structure (a single ref for a single data instance, one for a list, one for the errors). Maybe investigate how to abstract this so we don't have to repeat this in each service?
No description provided.