diff --git a/routes/views/accounts/get/report.js b/routes/views/accounts/get/report.js index e55393c5..89c7a389 100755 --- a/routes/views/accounts/get/report.js +++ b/routes/views/accounts/get/report.js @@ -100,16 +100,24 @@ exports = module.exports = function (req, res) { }); } - fs.readFile('members/recent.json', 'utf8', function (err, data) { - try { - locals.reportable_members = JSON.parse(data); - } catch (e) { - const moment = require('moment'); - console.log(moment().format("DD-MM-YYYY - HH:mm:ss") + "The list of reportable members could not be read from the disk: " + e.toString()); - } + locals.reportable_members = {}; + const recentMembersPath = 'members/recent.json'; + if (fs.existsSync(recentMembersPath)){ + fs.readFile(recentMembersPath, 'utf8', function (err, data) { + try { + locals.reportable_members = JSON.parse(data); + } catch (e) { + const moment = require('moment'); + console.log(moment().format("DD-MM-YYYY - HH:mm:ss") + " - The list of reportable members could not be read from the disk: " + e.toString()); + } - res.render('account/report', {flash: flash}); - }); + res.render('account/report', {flash: flash}); + }); + } + else + { + res.render('account/report', {flash: flash}); + } } ) }; diff --git a/routes/views/accounts/post/report.js b/routes/views/accounts/post/report.js index 19386217..c30243b2 100755 --- a/routes/views/accounts/post/report.js +++ b/routes/views/accounts/post/report.js @@ -124,7 +124,7 @@ exports = module.exports = async function (req, res) { // Checking the game exists if (isGameReport){ - const gameFetchRoute = process.env.API_URL+'/data/game?filter=id=='+req.body.game_id+'&fields[game]=id'; + const gameFetchRoute = process.env.API_URL+'/data/game?filter=id=='+req.body.game_id+'&fields[game]='; /* empty field here to fetch nothing but ID */ try { const gameFetch = await promiseRequest(gameFetchRoute); const gameData = JSON.parse(gameFetch);