-
-
Notifications
You must be signed in to change notification settings - Fork 581
Open
Labels
bugSomething isn't workingSomething isn't workinggood first issueStraightforward problem, solvable for first-time contributors without deep knowledge of the projectStraightforward problem, solvable for first-time contributors without deep knowledge of the projectopenapi-react-queryRelevant to openapi-react-queryRelevant to openapi-react-query
Description
openapi-fetch may return an error of value undefined
, when content length is 0 and response is not okay:
openapi-typescript/packages/openapi-fetch/src/index.js
Lines 205 to 208 in d4689b1
// handle empty content | |
if (response.status === 204 || response.headers.get("Content-Length") === "0") { | |
return response.ok ? { data: undefined, response } : { error: undefined, response }; | |
} |
However, openapi-react-query does not propagate this error, because the error is only propagated when error
is truthy, as per this code:
openapi-typescript/packages/openapi-react-query/src/index.ts
Lines 118 to 120 in d4689b1
if (error) { | |
throw error; | |
} |
To fix this, I believe this if (error)
check should be if (!response.ok)
and/or if ('error' in result)
.
We might also want to consider whether it makes sense for openapi-fetch to return undefined
as an error, in the scenario mentioned above.
EternalDeiwos
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workinggood first issueStraightforward problem, solvable for first-time contributors without deep knowledge of the projectStraightforward problem, solvable for first-time contributors without deep knowledge of the projectopenapi-react-queryRelevant to openapi-react-queryRelevant to openapi-react-query