From f3ae41cd2abed601c1f275b88166166a51480e8a Mon Sep 17 00:00:00 2001 From: Ro Date: Sat, 23 May 2020 13:29:28 -0700 Subject: [PATCH] cleaned up config file read for making new pages --- brain/routes/dash/pages.js | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/brain/routes/dash/pages.js b/brain/routes/dash/pages.js index bf53dd6..d1c03ae 100644 --- a/brain/routes/dash/pages.js +++ b/brain/routes/dash/pages.js @@ -92,14 +92,8 @@ router.get('/list/:filter?/:page?', function (req, res) { router.get('/add/new', function (req, res) { if (req.session.user) { //need to grab a few copy of settings for the lastest index - fs.readFile('site/settings.json', 'utf8', (err, json) => { - if (err) { - // TODO: add error page - //console.log('Error reading file from disk:', err); - return; - } - try { - let config = JSON.parse(json); + fs.readJSON('site/settings.json') + .then(config => { res.render('page-edit', { id: config.library_stats.current_index, uuid: uuidv4(), @@ -112,11 +106,8 @@ router.get('/add/new', function (req, res) { status: ['false', 'false', 'false'], edit: false }); - } catch (err) { - //add error page - console.log('ERROR', err); - } - }); + }) + .catch(err => {}); } else { res.redirect('/@/dashboard'); }