From 91f3b57cc0d8298e184c195dff0fddaa4f75fdc8 Mon Sep 17 00:00:00 2001 From: "gwenael.planchon" Date: Tue, 2 Apr 2024 17:17:36 +0200 Subject: [PATCH] s'ajouter dans la partie quand on rejoins la partie --- science-quest/src/data/kahoot.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/science-quest/src/data/kahoot.js b/science-quest/src/data/kahoot.js index 7405ee6..7ca53bb 100644 --- a/science-quest/src/data/kahoot.js +++ b/science-quest/src/data/kahoot.js @@ -4,12 +4,22 @@ import { Utilisateur } from "./utilisateur" export class Kahoot{ constructor(codeInvitation){ - this.codeInvitation=codeInvitation + this.codeInvitation=codeInvitation + this.rejoindrePartie().then() } async obtenirSalleAttente(){ const response=await fetch(`${REST_API}/partie/kahoot/${this.codeInvitation}/status`) return new KahootSalleAttente(await response.json()) } + async rejoindrePartie(){ + const user = await Utilisateur.utilisateurConnecteOuCreerInvite() + const response = await fetch(`${REST_API}/partie/kahoot/${this.codeInvitation}`,{ + method:"POST", + headers:{"Content-Type":"application/json"}, + body:JSON.stringify({"idJoueur":user.id}) + }) + return new this(await response.json()) + } }