fetcher throws error when quizId is ""

This commit is contained in:
nflnkr 2024-05-01 11:12:06 +03:00
parent a019843653
commit e72f5c8fca

@ -42,7 +42,7 @@ type PublicationMakeRequestParams = {
url: string;
body: FormData;
method: "POST";
}
};
export const publicationMakeRequest = ({ url, body }: PublicationMakeRequestParams) => {
return axios(url, {
@ -50,10 +50,10 @@ export const publicationMakeRequest = ({ url, body }: PublicationMakeRequestPara
headers: {
"X-Sessionkey": SESSIONS,
"Content-Type": "multipart/form-data",
"DeviceType" : DeviceType,
"Device" : Device,
"DeviceType": DeviceType,
"Device": Device,
"OS": OSDevice,
"Browser" : browserUser
"Browser": browserUser
},
method: "POST",
});
@ -72,10 +72,10 @@ export async function getData(quizId: string): Promise<{
headers: {
"X-Sessionkey": SESSIONS,
"Content-Type": "application/json",
"DeviceType" : DeviceType,
"Device" : Device,
"DeviceType": DeviceType,
"Device": Device,
"OS": OSDevice,
"Browser" : userAgent
"Browser": userAgent
},
data: {
quiz_id: quizId,
@ -105,6 +105,8 @@ export async function getData(quizId: string): Promise<{
}
export async function getQuizData(quizId: string) {
if (!quizId) throw new Error("No quiz id");
const response = await getData(quizId);
const quizDataResponse = response.data;
@ -127,7 +129,7 @@ type SendAnswerProps = {
body: string | string[];
qid: string;
preview: boolean;
}
};
export function sendAnswer({ questionId, body, qid, preview }: SendAnswerProps) {
if (preview) return;
@ -159,7 +161,7 @@ type SendFileParams = {
preview: boolean;
};
qid: string;
}
};
type Answer = {
question_id: string;
@ -201,7 +203,7 @@ export type SendFCParams = {
};
qid: string;
preview: boolean;
}
};
export function sendFC({ questionId, body, qid, preview }: SendFCParams) {
if (preview) return;