diff --git a/public/scripts/data.js b/public/scripts/data.js index 61f3923..502bbb8 100644 --- a/public/scripts/data.js +++ b/public/scripts/data.js @@ -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; }