diff --git a/src/topics/posts.js b/src/topics/posts.js index 98934a2f33..4345a177dd 100644 --- a/src/topics/posts.js +++ b/src/topics/posts.js @@ -43,8 +43,12 @@ module.exports = function(Topics) { Topics.addPostData = function(postData, uid, callback) { var pids = postData.map(function(post) { - return post.pid; - }); + return post && post.pid; + }).filter(Boolean); + + if (!Array.isArray(pids) || !pids.length) { + return callback(null, []); + } async.parallel({ favourites: function(next) {