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

refactor: generic fetch function in useTodoAPI #200

Open
olavis opened this issue Mar 13, 2023 · 2 comments
Open

refactor: generic fetch function in useTodoAPI #200

olavis opened this issue Mar 13, 2023 · 2 comments

Comments

@olavis
Copy link
Contributor

olavis commented Mar 13, 2023

        .catch((error: AxiosError<ErrorResponse>) => {
          throw new Error(error.message)
        })
          This one is repeated 4 times. Perhaps refactor?

Originally posted by @ingeridhellen in #195 (comment)

@olavis
Copy link
Contributor Author

olavis commented Mar 13, 2023

Looked into this, but I found it hard to find an elegant way to solve it in other ways than just writing a common catch function. In my opinion, the requests differ too much to make it worth it. The API lacks consistent response types and has built-in functions for create, getAll etc, instead of relying upon standard OpenAPI paths. It makes it hard to bring out the essence of the functions without adding extra checks. IMO, a common catch function would be a hasty abstraction (see AHA-programming), but I'll let the issue stay up for grabs if anyone wants to fix it from the backend. ✌️

@olavis
Copy link
Contributor Author

olavis commented Mar 15, 2023

#155 should be resolved first

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant