Top scorer data imported into league page
This commit is contained in:
@@ -90,19 +90,20 @@ app.use(fetchMatchesData);
|
||||
const convert_time = require('./resources/middleware/navigation-bar/convert-time');
|
||||
app.use(convert_time);
|
||||
|
||||
// Middleware function to fetch leagues data
|
||||
const fetchLeaguesData = require('./resources/middleware/league-page/get-current-league-information');
|
||||
const fetchLeagueScorerData = require('./resources/middleware/league-page/get-current-league-top-scorers');
|
||||
|
||||
// Define the route for fetching league data
|
||||
app.get('/league/:leagueID', fetchLeaguesData, (req, res) => {
|
||||
// Render the Handlebars view with league data
|
||||
res.render('pages/league-page', {
|
||||
leagueID: req.params.leagueID,
|
||||
leagues: res.locals.leagues
|
||||
});
|
||||
app.get('/league/:leagueID', [fetchLeaguesData, fetchLeagueScorerData], (req, res) => {
|
||||
// Render the Handlebars view with league data
|
||||
res.render('pages/league-page', {
|
||||
leagueID: req.params.leagueID,
|
||||
leagues: res.locals.leagues,
|
||||
scorers: res.locals.topScorers // Assuming fetchLeagueScorerData sets the data in res.locals.scorers
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
// *****************************************************
|
||||
// <!-- Section 5 : API Routes -->
|
||||
// *****************************************************
|
||||
|
||||
Reference in New Issue
Block a user