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

Error Handling in API Requests #33

Open
runeharlyk opened this issue Apr 2, 2024 · 1 comment
Open

Error Handling in API Requests #33

runeharlyk opened this issue Apr 2, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@runeharlyk
Copy link
Collaborator

Problem

Currently if a request fails the end user does not get notified of the result of the request.
Most fetch call is wrapped in a try catch that silently logs the error with console.error().

Proposal

An api service, which handles the unsuccessful requests and return a typed response. Something like:

await get<Networks>('/rest/listNetworks')

The service should:

  • Fetch the data with appropriate authentication
  • Notify the user (maybe via toast service) of any errors that occurred
  • Cast the json response to T type
  • return the data

Let me know if you are interested in the proposed feature.

@theelims theelims added the enhancement New feature or request label Apr 2, 2024
@theelims
Copy link
Owner

theelims commented Apr 2, 2024

I'm not a professional developer and used this project to learn JS/TS. So yes, there is a lot to improve.

I would also be interested in a more graceful behavior of the front end when the connection to the ESP is lost temporarily, or the ESP restarts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants