LAST COMMIT I HOPE

master
Aurian JAULT 2 years ago
parent a7ef15726f
commit e912930876

@ -17,9 +17,7 @@ class ApiService{
'Accept': 'application/json',
'Content-Type': 'application/json'
},
body: JSON.stringify({
word:"yessss"
})
body: JSON.stringify(value)
};
fetch(baseUrl, headers).then( (response) => {
if (response.ok)

@ -121,21 +121,33 @@ export default{
const equipe1 = document.querySelector("#equipe1").value
const equipe2 = document.querySelector("#equipe2").value
const equipe1Score = document.querySelector("#equipe1Score").value
const equipe2Score = document.querySelector("#equipe2Score").value
const stringEquipe1Score = document.querySelector("#equipe1Score").value
const stringEquipe2Score = document.querySelector("#equipe2Score").value
const equipe1Score = parseInt(stringEquipe1Score);
const equipe2Score = parseInt(stringEquipe2Score);
const res = this.teams.filter(item => item.name === equipe1)
const res2 = this.teams.filter(item => item.name === equipe2)
console.log(res)
console.log(res2)
let tab = [res,res2]
if (equipe1Score=="" || equipe2Score=="") {
this.errMessageMatch="Veuillez rentrer le score de TOUTES les equipes";
return;
}
const JSON = `[{"name":${equipe1},"score":${equipe1Score}},{"name":${equipe2},"score":${equipe2Score}}]`
if (equipe1Score < 0 || equipe2Score < 0) {
this.errMessageMatch = "Veuilez rentre un score positif";
return
}
try {
const api = ApiService();
api.post("http://www.post-result.com",JSON)
api.post("http://www.post-result.com",tab)
} catch (Error) {
this.errMessageMatch="Une erreur sur la requette POST"
}

Loading…
Cancel
Save