HoshiAI-app/api/_client.ts
2026-01-02 15:58:21 +01:00

39 lines
982 B
TypeScript

import axiosInstance from "./_axiosInstance";
import { AuthLoginResponse, Pagination, QuestionResponse, UserResponse } from "./types";
export const get_questions = async (page: number, test_id?: number, question_id?: number) => {
const response = await axiosInstance.get<Pagination<QuestionResponse>>("/api/questions/", {
params: {
page,
test_id,
question_id
}
})
return response.data;
}
export const get_question = async (id: number) => {
const response = await axiosInstance.get<{
data: QuestionResponse
}>(`/api/questions/${id}`);
return response.data;
}
export const get_current_user = async () => {
const response = await axiosInstance.get<{
user: UserResponse
}>("/api/auth/me/");
return response.data;
}
export const post_login = async (email: string, password: string) => {
const response = await axiosInstance.post<AuthLoginResponse>("/api/auth/login/", {
email,
password
});
return response.data;
}