export async function getSports() { const response = await fetch(`/data/sports`); const sportsList = await response.json(); return sportsList; } export async function getSportName(sportID) { const response = await fetch(`/data/sport?sport=${sportID}`); const sport = await response.json(); return sport.name; } export async function getSeasons() { const response = await fetch(`/data/seasons`); const seasonsList = await response.json(); return seasonsList; } export async function getGenders(sportID) { const response = await fetch(`/data/genders?sport=${+sportID}`); const gendersList = await response.json(); return gendersList; } export async function getDivisions(sportID = undefined, gender = undefined) { let URL = '/data/divisions?'; if(sportID) URL += `sport=${+sportID}&`; if(gender) URL += `gender=${gender}&`; const response = await fetch(URL); const divisionsList = await response.json(); return divisionsList; } export async function getDivision(divisionID) { const response = await fetch(`/data/division?division=${divisionID}`); const division = await response.json(); return division; } export async function getTeams(sportID = undefined) { let URL = '/data/teams?'; if(sportID) URL += `sport=${+sportID}&`; const response = await fetch(URL); const teamsList = await response.json(); return teamsList; } export async function getTeam(teamID) { const response = await fetch(`/data/team?team=${+teamID}`); const team = await response.json(); return team; } export async function getGames(teamID = undefined, divisionID = undefined, seasonID = undefined) { let URL = '/data/games?'; if(teamID) URL += `team=${+teamID}&`; if(divisionID) URL += `division=${+divisionID}&`; if(seasonID) URL += `season=${+seasonID}`; const response = await fetch(URL); const gamesList = await response.json(); return gamesList; } export async function getGamesByUser() { let URL = '/data/games?user=1'; const response = await fetch(URL); const gamesList = await response.json(); return gamesList; } export async function getGame(gameID) { const response = await fetch(`/data/game?game=${gameID}`); const game = await response.json(); return game; } export async function getLatestGame(ofUser = false) { let URL = `/data/game?`; if(ofUser) URL += `ofuser=1`; const response = await fetch(URL); const game = await response.json(); return game; } export async function getAccounts() { const response = await fetch(`/data/accounts`); const accounts = await response.json(); return accounts; } export async function getAccount(accountID) { const response = await fetch(`/data/account?account=${accountID}`); const account = await response.json(); return account; }