Add option to fetch all divisions

main
sudoer777 2021-11-22 14:58:43 -07:00
parent 4aafccc550
commit 75594a81a6
1 changed files with 6 additions and 2 deletions

View File

@ -16,8 +16,12 @@ export async function getGenders(sportID) {
return gendersList;
}
export async function getDivisions(sportID, gender) {
const response = await fetch(`/data/divisions?sport=${+sportID}&gender=${gender}`);
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;
}