Skip to content
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

Merged
merged 21 commits into from
Mar 22, 2024
Merged

chore: add student service #147

merged 21 commits into from
Mar 22, 2024

Conversation

tyboro2002
Copy link
Contributor

No description provided.

@tyboro2002 tyboro2002 added the frontend Issues regarding the frontend label Mar 21, 2024
@tyboro2002 tyboro2002 added this to the Frontend milestone milestone Mar 21, 2024
@tyboro2002 tyboro2002 requested a review from EwoutV March 21, 2024 14:13
@tyboro2002 tyboro2002 self-assigned this Mar 21, 2024

axios.get(endpoint).then(response => {
student.value = Student.fromJSON(response.data);
}).catch(error => {
Copy link
Contributor

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?

@tyboro2002 tyboro2002 marked this pull request as ready for review March 22, 2024 16:52
frontend/src/config/endpoints.ts Outdated Show resolved Hide resolved
frontend/src/config/endpoints.ts Outdated Show resolved Hide resolved
frontend/src/types/Admin.ts Show resolved Hide resolved
@tyboro2002 tyboro2002 merged commit 5491f2a into development Mar 22, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
frontend Issues regarding the frontend
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants