api ulandi
This commit is contained in:
@@ -69,7 +69,29 @@ export default function LoginForm() {
|
||||
},
|
||||
onError: (error: AxiosError) => {
|
||||
const data = error.response?.data as { message?: string };
|
||||
toast.error(data?.message || "Xatolik yuz berdi");
|
||||
const errorData = error.response?.data as {
|
||||
messages?: {
|
||||
token_class: string;
|
||||
token_type: string;
|
||||
message: string;
|
||||
}[];
|
||||
};
|
||||
const errorName = error.response?.data as {
|
||||
data?: {
|
||||
name: string[];
|
||||
};
|
||||
};
|
||||
|
||||
const message =
|
||||
Array.isArray(errorName.data?.name) && errorName.data.name.length
|
||||
? errorName.data.name[0]
|
||||
: data?.message ||
|
||||
(Array.isArray(errorData?.messages) && errorData.messages.length
|
||||
? errorData.messages[0].message
|
||||
: undefined) ||
|
||||
"Xatolik yuz berdi";
|
||||
|
||||
toast.error(message);
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user