posts post endpoint

This commit is contained in:
Daniel Lugo 2020-06-16 13:07:46 -04:00
parent ea77a4dd7e
commit 230228713d

View file

@ -1757,19 +1757,18 @@ module.exports = async (
} }
}) })
app.post(`/api/gun/wall`, async (req,res) => { app.post(`/api/gun/wall/`, async (req,res) => {
try{ try{
const {tags,title,contentItems} = req.body 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) { } catch(e) {
const {tags,title,contentItems} = req.body return res.status(500).json({
if(!tags || !title || !contentItems) { errorMessage: (typeof e === 'string' ? e : e.message)
res.status(400).json({ || 'Unknown error.'
errorMessage: 'missing params'
})
}
res.status(500).json({
errorMessage: typeof e === 'string' ? e : e.message
}) })
} }
}) })