function goTo() { window.open("https://discord.com/api/oauth2/authorize?client_id=356104008366030863&redirect_uri=https%3A%2F%2Frem.wordfights.com%2FcreateLeague&response_type=token&scope=identify") } function goToLeague(recordID) { location.replace(location.origin+'/league/'+recordID) } window.onload = ()=> { presentLeagues(); } async function presentLeagues() { var leagues = await fetch(`${window.location.origin}/api/getAllLeagues`, { method: "GET", }) .then(res=>{return res.json()}) .then(response=> { return response.data; }) .catch(console.error) var table = document.getElementById('LeaguesTable'); var rows = ''; for(var league of leagues) { (async (league)=> { var aux = ` ${league.Name} ${league.Players.length} ` rows+=aux; })(league) } var auxHTML = ` ${rows}
League Players
` table.innerHTML = auxHTML; }