diff --git a/routes/likeRouter.js b/routes/likeRouter.js index 22a3b37..26e617b 100644 --- a/routes/likeRouter.js +++ b/routes/likeRouter.js @@ -29,6 +29,11 @@ router.get('/', function(request, response) { WHERE post.id = liked.postId and liked.userId=${request.user.id} group by post.id`, function(err, result) { + if(result.length == 0){ + response.send(''); + }else{ + var list =''; var date = dateFormat(result[0].createdate); @@ -53,6 +58,8 @@ router.get('/', function(request, response) { var body = template.HOME(list, request.user); var html = template.HTML(body); response.send(html); + } + }) } }); diff --git a/routes/myboardRouter.js b/routes/myboardRouter.js index 4ce0769..141df85 100644 --- a/routes/myboardRouter.js +++ b/routes/myboardRouter.js @@ -25,30 +25,39 @@ router.get('/', function(request, response) { db.query(`SELECT post.id, post.title, post.createdate, count(liked.id) 'count' FROM (SELECT * FROM post WHERE post.userId=${request.user.id}) post left join liked on post.id = liked.postId group by post.id`, function(err, result) { - if (err) throw err; - console.log(result) - var list =''; - - var date = dateFormat(result[0].createdate); - - for (var i = 0;i < result.length; i++) { - list += ` -
- -
-

${result[i].title}

-
${request.user.nickname} | ${date}
-
-
-
- -
${result[i].count}
-
-
- ` + + if (result.length == 0){ + response.send(''); + }else{ + if (err) throw err; + + var list =''; + + var date = dateFormat(result[0].createdate); + + for (var i = 0;i < result.length; i++) { + list += ` +
+ +
+

${result[i].title}

+
${request.user.nickname} | ${date}
+
+
+
+ +
${result[i].count}
+
+
+ ` + } + const body = boardlist.HOME(list, request.user); + response.send(boardlist.HTML(body)); } - const body = boardlist.HOME(list, request.user); - response.send(boardlist.HTML(body)); + + + }) } }); diff --git a/template/board.js b/template/board.js index a2928f4..220672d 100644 --- a/template/board.js +++ b/template/board.js @@ -136,7 +136,7 @@ module.exports = { -
+