Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/authProvider.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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",
},
};
}
},
Expand Down