From 230228713dc1ab00a7d1a707dc2a4086f25eaa1f Mon Sep 17 00:00:00 2001 From: Daniel Lugo Date: Tue, 16 Jun 2020 13:07:46 -0400 Subject: [PATCH] posts post endpoint --- src/routes.js | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/routes.js b/src/routes.js index 48c08b65..b15774bc 100644 --- a/src/routes.js +++ b/src/routes.js @@ -1757,19 +1757,18 @@ module.exports = async ( } }) - app.post(`/api/gun/wall`, async (req,res) => { + app.post(`/api/gun/wall/`, async (req,res) => { try{ const {tags,title,contentItems} = req.body - res.status(201).json(await GunActions.createPost(title,tags,contentItems)) + return res.status(201).json(await GunActions.createPost( + tags, + title, + contentItems + )) } catch(e) { - const {tags,title,contentItems} = req.body - if(!tags || !title || !contentItems) { - res.status(400).json({ - errorMessage: 'missing params' - }) - } - res.status(500).json({ - errorMessage: typeof e === 'string' ? e : e.message + return res.status(500).json({ + errorMessage: (typeof e === 'string' ? e : e.message) + || 'Unknown error.' }) } })