From 22e1b0f22e9c0d7530a3650f8dbbb35e8771d812 Mon Sep 17 00:00:00 2001 From: Baris Soner Usakli Date: Fri, 17 Jan 2014 18:12:56 -0500 Subject: [PATCH] check result for null --- src/routes/api.js | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/src/routes/api.js b/src/routes/api.js index 9beb247c09..119bc2334f 100644 --- a/src/routes/api.js +++ b/src/routes/api.js @@ -279,12 +279,7 @@ var path = require('path'), return callback(err, null); } - posts.getPostSummaryByPids(pids, false, function (err, posts) { - if (err){ - return callback(err, null); - } - callback(null, posts); - }); + posts.getPostSummaryByPids(pids, false, callback); }); } @@ -294,12 +289,7 @@ var path = require('path'), return callback(err, null); } - topics.getTopicsByTids(tids, 0, 0, function (err, topics) { - if (err){ - return callback(err, null); - } - callback(null, topics); - }); + topics.getTopicsByTids(tids, 0, 0, callback); }); } @@ -309,6 +299,10 @@ var path = require('path'), return next(err); } + if(!results) { + results[0] = results[1] = []; + } + return res.json({ show_no_topics: results[1].length ? 'hide' : '', show_no_posts: results[0].length ? 'hide' : '',