refactor: generic fetch function in useTodoAPI
.catch((error: AxiosError<ErrorResponse>) => {
throw new Error(error.message)
})
This one is repeated 4 times. Perhaps refactor?
Originally posted by @ingeridhellen in https://github.com/equinor/template-fastapi-react/pull/195#discussion_r1132372291
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. ✌️
#155 should be resolved first