From 75594a81a6497272941e897485797a9b9728ff74 Mon Sep 17 00:00:00 2001 From: sudoer777 <78781902+sudoer777@users.noreply.github.com> Date: Mon, 22 Nov 2021 14:58:43 -0700 Subject: [PATCH] Add option to fetch all divisions --- public/scripts/data.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) 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; }