Updates to file structure

This commit is contained in:
Lucas Patenaude
2024-04-30 22:12:59 -06:00
parent 289e7641b4
commit bd79a6ccc3
71 changed files with 14 additions and 14 deletions

View File

@@ -0,0 +1,17 @@
const express = require('express');
const app = express();
// generate-league-routes.js
// Define a function to generate league routes
module.exports = function generateLeagueRoutes(app) {
// Define a route to handle requests to "/league/:leagueName"
app.get('/league/:leagueID', (req, res) => {
// Extract the league name from the URL parameters
const leagueID = req.params.leagueID;
// Render the league page template using Handlebars
res.render('pages/leagues-page', { leagueID: leagueID, user: user});
});
};

View File

@@ -0,0 +1,21 @@
const axios = require('axios');
const fetchTeamNames = async (selectedLeague) => {
try {
const response = await axios({
url: `http://api.football-data.org/v4/competitions/${selectedLeague}/teams`,
method: 'GET',
headers: {
'X-Auth-Token': '0aa1ed31245d4a36b1ef5a79150324b3',
},
});
const teams = response.data.teams.map(team => team.name);
return teams;
} catch (error) {
console.error('Error fetching teams data:', error);
return [];
}
};
module.exports = fetchTeamNames;

View File

@@ -0,0 +1,7 @@
function redirectToLeaguePage(leagueID) {
// Append the league name to the URL
var url = "/league/" + leagueID;
// Redirect to the league page
window.location.href = url;
}