32 lines
887 B
TypeScript
32 lines
887 B
TypeScript
![]() |
import { makeRequest } from "@frontend/kitui";
|
|||
|
|
|||
|
import type { LoginRequest, LoginResponse } from "@frontend/kitui";
|
|||
|
import { parseAxiosError } from "../utils/parse-error";
|
|||
|
|
|||
|
const apiUrl = process.env.REACT_APP_DOMAIN + "/statistic";
|
|||
|
|
|||
|
export type DevicesResponse = {
|
|||
|
device: Record<string, number>;
|
|||
|
os: Record<string, number>;
|
|||
|
browser: Record<string, number>;
|
|||
|
};
|
|||
|
|
|||
|
export const getDevicesList = async (
|
|||
|
quizId: string,
|
|||
|
): Promise<[any | null, string?]> => {
|
|||
|
try {
|
|||
|
const devicesResponse = await makeRequest<unknown, DevicesResponse>({
|
|||
|
method: "POST",
|
|||
|
url: `${apiUrl}/devices?quizID=${quizId}`,
|
|||
|
useToken: false,
|
|||
|
withCredentials: true,
|
|||
|
});
|
|||
|
|
|||
|
return [devicesResponse];
|
|||
|
} catch (nativeError) {
|
|||
|
const [error] = parseAxiosError(nativeError);
|
|||
|
|
|||
|
return [null, `Не получить статистику о девайсах. ${error}`];
|
|||
|
}
|
|||
|
};
|