openapi-typescript
openapi-typescript copied to clipboard
openapi-react-query does not propagate `undefined` errors from openapi-fetch
openapi-fetch may return an error of value undefined, when content length is 0 and response is not okay: https://github.com/openapi-ts/openapi-typescript/blob/d4689b10af870b6978e5c6107a55fff044936b39/packages/openapi-fetch/src/index.js#L205-L208
However, openapi-react-query does not propagate this error, because the error is only propagated when error is truthy, as per this code: https://github.com/openapi-ts/openapi-typescript/blob/d4689b10af870b6978e5c6107a55fff044936b39/packages/openapi-react-query/src/index.ts#L118-L120
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.
That makes completely sense, happy to review a PR for that!