Open jokiefer opened 2 years ago
drop this... the response is part of the error. The reason why i didn't find it directly is that there is a type mismatch:
// file: react-openapi-client/useOperationMethod.d.ts
import { UnknownOperationMethod, OpenAPIClientAxios, AxiosResponse } from 'openapi-client-axios';
export declare function useOperationMethod(operationId: string): [
UnknownOperationMethod,
{
loading: boolean;
error?: Error;
data?: any;
response: AxiosResponse;
api: OpenAPIClientAxios;
}
];
Fixing the typescript mismatch:
const axiosError = error as AxiosError;
console.log('response', axiosError?.response);
Status quo
currently the response state variable is undefined if any error occurs.
Client errors like bad request (http 400) with server side error messages are missing. Without that it is not possible to handle errors on client side.