Fix bug where games don't load if user is not logged in
parent
3201ffb2a9
commit
bb335c7aca
|
@ -177,11 +177,14 @@ genderDropdown.onchange = listDivisions;
|
|||
teamDropdown.onchange = listGames;
|
||||
seasonDropdown.onchange = listGames;
|
||||
|
||||
|
||||
if(addScoreButton) {
|
||||
addScoreButton.addEventListener('click', () => {
|
||||
window.location.href = '/manage/game';
|
||||
});
|
||||
}
|
||||
|
||||
if(manageButton) {
|
||||
manageButton.addEventListener('click', () => {
|
||||
window.location.href = '/manage'
|
||||
});
|
||||
}
|
||||
|
|
|
@ -71,7 +71,7 @@ router.get('/team', function(req, res, next) {
|
|||
})
|
||||
|
||||
router.get('/games', function(req, res, next) {
|
||||
const userID = req.user[0];
|
||||
const userID = req.user ? req.user[0] : null;
|
||||
if(req.query.user) games.retrieveByUser(userID).then(data => res.json(data));
|
||||
else games.retrieve(req.query.team, req.query.division, req.query.season).then(data => res.json(data));
|
||||
})
|
||||
|
|
Reference in New Issue