Skip to content
Snippets Groups Projects
Commit f065f8a9 authored by GOEPP THOMAS's avatar GOEPP THOMAS
Browse files

feat: new service

parent 3bc4d53d
Branches
2 merge requests!132V4.0,!129Feature/135 refacto lobby
import axios from "axios";
import {QuestionResponse} from "../models/Response/QuestionResponse";
import HttpError from "./HttpError";
export const useMultiService = () => {
const url = "https://klebert-host.com:33037"
const createParty = async (quizId: string) : Promise<string | HttpError> => {
console.log("Create party with ID :", quizId);
console.log(url+"/party");
const requestBody = {
quizId: quizId,
};
try {
const response = await axios.post(`${url}/party`, requestBody, {
withCredentials: true,
});
console.log("Response data:", response.data.id);
return response.data.id;
} catch (error: any) {
console.log("Error while create party:", error);
if (error.response) {
return new HttpError(error.response.status, error.response.data?.message || "HTTP error");
} else {
return new HttpError(500, "Unexpected error: " + error.message);
}
}
}
return {
createParty: createParty,
}
}
\ No newline at end of file
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment