You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For now, the onError receive as argument Response["error”], it content the body of the response, but you are not able to access the status code of the response which could be interesting if you have different body between with code 400 or 404.
Proposal
Maybe it needs to change too much things. I presume what needs to be change is GetResponseContent from openapi-typescript-helpers
typeGetResponseContent<TextendsRecord<string|number,any>,MediaextendsMediaType=MediaType,ResponseCodeextendskeyofT=keyofT,>=ResponseCodeextendskeyofT
? {[KinResponseCode]: T[K]["content"]extendsRecord<string,any>
? FilterKeys<T[K]["content"],Media>extendsnever
? T[K]["content"]
: FilterKeys<T[K]["content"],Media>
: KextendskeyofT
? T[K]["content"]
: never;}[ResponseCode]
: never;/** * Return all 5XX and 4XX responses (in that order) from a Response Object Map */exporttypeErrorResponse<TextendsRecord<string|number,any>,MediaextendsMediaType=MediaType,>=GetResponseContent<T,Media,ErrorStatus>;
Or maybe the query function (openapi-react-query) could return the response object instead of only the error.
constqueryFn=async<MethodextendsHttpMethod,PathextendsPathsWithMethod<Paths,Method>>({queryKey: [method,path,init],
signal,}: QueryFunctionContext<QueryKey<Paths,Method,Path>>)=>{constmth=method.toUpperCase()asUppercase<typeofmethod>;constfn=client[mth]asClientMethod<Paths,typeofmethod,Media>;const{ data, error, response }=awaitfn(path,{ signal, ...(initasany)});// TODO: find a way to avoid as anyif(error){throwerror;// Could throw {response, error}}returndata;};
I can contribute but tell me if there already a solution
Description
For now, the onError receive as argument Response["error”], it content the body of the response, but you are not able to access the status code of the response which could be interesting if you have different body between with code 400 or 404.
Proposal
Maybe it needs to change too much things. I presume what needs to be change is GetResponseContent from openapi-typescript-helpers
Or maybe the query function (openapi-react-query) could return the response object instead of only the error.
I can contribute but tell me if there already a solution
Extra
The text was updated successfully, but these errors were encountered: