From fba39bec1d24ed1758713ba7b18a3dd2854f6df0 Mon Sep 17 00:00:00 2001 From: Nastya Date: Tue, 20 May 2025 13:56:34 +0300 Subject: [PATCH] fix axios error --- lib/api/quizRelase.ts | 10 +++++++++- lib/components/ViewPublicationPage/ApologyPage.tsx | 4 ++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/api/quizRelase.ts b/lib/api/quizRelase.ts index 5be0530..f72ef9c 100644 --- a/lib/api/quizRelase.ts +++ b/lib/api/quizRelase.ts @@ -186,7 +186,15 @@ export async function getQuizData({ quizId, status = "" }: { quizId: string; sta const quizDataResponse = response.data; if (response.error) { - throw response.error; + const axiosError = response.error as AxiosError; + if (axiosError.response?.data) { + throw new Error( + typeof axiosError.response.data === "string" + ? axiosError.response.data + : JSON.stringify(axiosError.response.data) + ); + } + throw axiosError; } if (!quizDataResponse) { throw new Error("Quiz not found"); diff --git a/lib/components/ViewPublicationPage/ApologyPage.tsx b/lib/components/ViewPublicationPage/ApologyPage.tsx index 9694685..a6afa60 100644 --- a/lib/components/ViewPublicationPage/ApologyPage.tsx +++ b/lib/components/ViewPublicationPage/ApologyPage.tsx @@ -6,7 +6,11 @@ type Props = Partial; export const ApologyPage = ({ error }: Props) => { let message = error.message || error.response?.data; + console.log("message"); + console.log(message.toLowerCase()); const { t } = useTranslation(); + console.log("t"); + console.log(t(message.toLowerCase())); return (