2021-11-21 22:30:54 +00:00
|
|
|
export async function getSports() {
|
2021-11-22 22:30:02 +00:00
|
|
|
const response = await fetch(`/data/sports`);
|
2021-11-21 22:30:54 +00:00
|
|
|
const sportsList = await response.json();
|
|
|
|
return sportsList;
|
2021-11-21 22:40:48 +00:00
|
|
|
}
|
|
|
|
|
2021-11-22 22:30:02 +00:00
|
|
|
export async function getSportName(sportID) {
|
|
|
|
const response = await fetch(`/data/sport?sport=${sportID}`);
|
|
|
|
const sport = await response.json();
|
|
|
|
return sport.name;
|
|
|
|
}
|
|
|
|
|
2021-11-21 22:40:48 +00:00
|
|
|
export async function getSeasons() {
|
2021-11-22 22:30:02 +00:00
|
|
|
const response = await fetch(`/data/seasons`);
|
2021-11-21 22:40:48 +00:00
|
|
|
const seasonsList = await response.json();
|
|
|
|
return seasonsList;
|
2021-11-21 23:24:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export async function getGenders(sportID) {
|
|
|
|
const response = await fetch(`/data/genders?sport=${+sportID}`);
|
|
|
|
const gendersList = await response.json();
|
|
|
|
return gendersList;
|
2021-11-21 23:48:03 +00:00
|
|
|
}
|
|
|
|
|
2021-11-22 21:58:43 +00:00
|
|
|
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);
|
2021-11-21 23:48:03 +00:00
|
|
|
const divisionsList = await response.json();
|
|
|
|
return divisionsList;
|
2021-11-22 00:15:02 +00:00
|
|
|
}
|
|
|
|
|
2021-11-22 23:27:50 +00:00
|
|
|
export async function getDivision(divisionID) {
|
|
|
|
const response = await fetch(`/data/division?division=${divisionID}`);
|
|
|
|
const division = await response.json();
|
|
|
|
return division;
|
|
|
|
}
|
|
|
|
|
2021-11-22 22:45:19 +00:00
|
|
|
export async function getTeams(sportID = undefined) {
|
|
|
|
let URL = '/data/teams?';
|
|
|
|
if(sportID) URL += `sport=${+sportID}&`;
|
|
|
|
|
|
|
|
const response = await fetch(URL);
|
2021-11-22 00:15:02 +00:00
|
|
|
const teamsList = await response.json();
|
|
|
|
return teamsList;
|
2021-11-22 04:59:07 +00:00
|
|
|
}
|
|
|
|
|
2021-11-23 06:45:24 +00:00
|
|
|
export async function getTeam(teamID) {
|
2021-11-22 04:59:07 +00:00
|
|
|
const response = await fetch(`/data/team?team=${+teamID}`);
|
|
|
|
const team = await response.json();
|
2021-11-23 06:45:24 +00:00
|
|
|
return team;
|
2021-11-22 04:59:07 +00:00
|
|
|
}
|
|
|
|
|
2021-11-22 23:00:12 +00:00
|
|
|
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);
|
2021-11-22 04:59:07 +00:00
|
|
|
const gamesList = await response.json();
|
|
|
|
return gamesList;
|
2021-11-21 22:30:54 +00:00
|
|
|
}
|