Open
Description
Models generated with openapi-typescript-codegen
contain the correctly inferred types from our OpenAPI Spec, but also the structure for the error object.
That should probably not be the case adds unnecessary of guarding code when calling the api functions.
Example:
const { data: favorites, isLoading } = useQuery({
queryKey: ["favorites"],
queryFn: async () => {
const result = await api.getFavorites();
if ("status" in result) throw new Error(result.title, { cause: result });
return result.favorites;
},
initialData: () => [],
});
It seems like the generated client should throw (and therefore not resolve) in any case when response.ok
is not true:
Metadata
Metadata
Assignees
Labels
No labels