diff --git a/src/authProvider.ts b/src/authProvider.ts index 55e109b..1bd1056 100644 --- a/src/authProvider.ts +++ b/src/authProvider.ts @@ -1,7 +1,7 @@ import { AuthBindings } from "@refinedev/core"; import { TOKEN_KEY, API_URL } from "./constants"; -import axios, { AxiosInstance } from "axios"; +import axios, { AxiosInstance,AxiosError } from "axios"; export const authProvider = (axiosInstance: AxiosInstance): AuthBindings => { return { @@ -17,10 +17,14 @@ export const authProvider = (axiosInstance: AxiosInstance): AuthBindings => { success: true, redirectTo: "/", }; - } catch (error: any) { + } catch (error: unknown) { //By this way Users will get a structured error instead of raw one. + const err = error as AxiosError<{ errors?: string[] }>; return { success: false, - error, + error: { + message: err.response?.data?.errors?.[0] || err.message, + name: "LoginError", + }, }; } },