tries to add api requests

This commit is contained in:
unurled 2025-07-05 10:22:33 +02:00
parent e841c38573
commit 73c32b4fb6
26 changed files with 962 additions and 39 deletions

View file

@ -22,25 +22,19 @@
tournament.teams.push({ name: teamName });
// post request to /tournaments/{tournament}/addTeam
const response = await fetch(`/api/tournaments/${tournament.id}/addTeam`, {
method: 'POST',
body: JSON.stringify({ teamName: teamName }),
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
team_name: teamName,
}),
});
if (response.ok) {
addTeam = false;
teamName = '';
} else {
// handle error
console.log('response', JSON.stringify(response));
const data = await response.json();
console.log('data', JSON.stringify(data));
console.log('data', data, JSON.stringify(data));
tournament = data;
} else {
console.log('response not ok', JSON.stringify(response));
}
}
</script>