Padel-Tournaments-System/frontend/app.js

35 lines
1.1 KiB
JavaScript
Raw Normal View History

async function showTournaments() {
let url = 'https://dragonmaster.pl/inz/tournaments';
try {
let res = await fetch(url);
return await res.json();
} catch (error) {
console.log(error);
}
}
async function renderTournaments() {
let tournaments = await showTournaments();
let html = '';
tournaments.forEach(tournament => {
let htmlSegment = `<div class = "tournamentBox">
<div class="tournamentIconBox">
<img class="tournamentIcon" src="_main%20page/cup.svg" alt="">
</div>
<div class="tournamentDataBox">
<div class="tournamentData">
<h4>${tournament.name}</h4>
Propadel, Warszawa
${tournament.from} do ${tournament.to}
<button class="tournamentOpen">OPEN</button>
</div>
</div>
</div>
`;
html += htmlSegment;
});
let container = document.querySelector('.tournament-list');
container.innerHTML = html;
}