From: Benjamin Auder Date: Tue, 18 Feb 2020 18:01:29 +0000 (+0100) Subject: Bug when editing news just posted X-Git-Url: https://git.auder.net/doc/html/css/current/pieces/assets/rpsls.css?a=commitdiff_plain;h=8eb8e9b271debcde7bdd687ad2f6becbfefa9046;p=vchess.git Bug when editing news just posted --- diff --git a/client/src/views/News.vue b/client/src/views/News.vue index 5b2c80fe..1509d67d 100644 --- a/client/src/views/News.vue +++ b/client/src/views/News.vue @@ -57,7 +57,7 @@ export default { }, created: function() { ajax("/news", "GET", { cursor: this.cursor }, res => { - this.newsList = res.newsList.sort((n1, n2) => n1.added - n2.added); + this.newsList = res.newsList.sort((n1, n2) => n2.added - n1.added); const L = res.newsList.length; if (L > 0) this.cursor = this.newsList[0].id; }); diff --git a/server/routes/news.js b/server/routes/news.js index ed784564..dbd6d382 100644 --- a/server/routes/news.js +++ b/server/routes/news.js @@ -20,7 +20,7 @@ router.post("/news", access.logged, access.ajax, (req,res) => { return res.json({errmsg: "Not allowed to post"}); const content = sanitizeHtml(req.body.news.content); NewsModel.create(content, req.userId, (err,ret) => { - return res.json(err || {nid:ret.nid}); + return res.json(err || {id:ret.nid}); }); });