diff --git a/public/scripts/manage.js b/public/scripts/manage.js index a96bac9..6fc6b07 100644 --- a/public/scripts/manage.js +++ b/public/scripts/manage.js @@ -166,7 +166,7 @@ CATEGORIES.push(new Category( CATEGORIES.push(new Category( "teams", async function getTeams() { - return await Data.getTeams(); + return await (await fetch('/fetch/manage/teams')).json(); }, async function listTeamHeaders() { const headerRow = document.createElement('tr'); @@ -194,8 +194,8 @@ CATEGORIES.push(new Category( row.appendChild(spacerCell); const sportCell = document.createElement('td'); - Data.getSportName(team.sportID) - .then(data => sportCell.textContent = data); + let sportName = team.sport.name; + sportCell.textContent = sportName; row.appendChild(sportCell); }, async function addTeam() { diff --git a/routes/fetch.js b/routes/fetch.js index 28a98ea..c140ead 100644 --- a/routes/fetch.js +++ b/routes/fetch.js @@ -136,4 +136,14 @@ router.get('/manage/divisions', async function (req, res, next) { res.json(data); }); +router.get('/manage/teams', async function (req, res, next) { + const data = await teams.retrieve(); + + for(const team of data) { + team.sport = await sports.getFromID(team.sportID); + } + + res.json(data); +}); + module.exports = router; \ No newline at end of file