// function lodaDoc() { // var xhttp = new XMLHttpRequest(); // xhttp.onreadystatechange = function () { // if (this.readyState == 4 && this.status == 200) { // document.getElementById("demo").innerHTML = this.responseText; // } // }; // xhttp.open("GET", "https://dragonmaster.pl/inz/tournaments"); // xhttp.send(); // } // let response = fetch(URL); // const ul = document.getElementById('tournaments'); // const list = document.createDocumentFragment(); // const url = 'https://dragonmaster.pl/inz/tournaments' // let tablica; // fetch(url).then(function (response) { // return response.json(); // }).then(function (obj) { // let id; // let count; // tablica = obj // console.log(obj); // for (id in tablica) { // console.log(tablica.name); // ++count; // } // }).catch(function (error) { // console.error('Something went wrong!') // console.error(error); // }); 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 = `

${tournament.name}

${tournament.place}

${tournament.from} do ${tournament.to}

`; html += htmlSegment; }); let container = document.querySelector('.tournament-list'); container.innerHTML = html; } function register() { fetch('https://dragonmaster.pl/inz/user/create', { method: "PUT", headers: { 'Content-type': 'application/json' }, body: JSON.stringify( { "username": "jaro", "name": "maro", "surname": "siaro", "password": "jaro", "mail": "jaro@wp.pl", "phone": "1234567" } ) } ) .then(res => { if (res.ok) { alert("Teraz mozesz się zalogować!") window.open("../panel_organizatora/logowanie/index.html"); } else { console.log("Coś poszło nie tak!") } return res }) .then(res => res.json()) .then(data => console.log(data)) .catch(error => console.log(error)) }