s'ajouter dans la partie quand on rejoins la partie
continuous-integration/drone/push Build is passing Details

front
Gwenael PLANCHON 1 year ago
parent 03daf1d8fd
commit 91f3b57cc0

@ -4,12 +4,22 @@ import { Utilisateur } from "./utilisateur"
export class Kahoot{ export class Kahoot{
constructor(codeInvitation){ constructor(codeInvitation){
this.codeInvitation=codeInvitation this.codeInvitation=codeInvitation
this.rejoindrePartie().then()
} }
async obtenirSalleAttente(){ async obtenirSalleAttente(){
const response=await fetch(`${REST_API}/partie/kahoot/${this.codeInvitation}/status`) const response=await fetch(`${REST_API}/partie/kahoot/${this.codeInvitation}/status`)
return new KahootSalleAttente(await response.json()) 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())
}
} }

Loading…
Cancel
Save