const Promise = require('promise'); const sql = require('../utils/sql'); module.exports= { main: function(res) { console.log("sidebar called"); return new Promise(function(resolve, reject) { res.write("
"); res.write("

Popular Posts

"); res.write("
"); sql.getPopularPosts().then(function(posts) { posts.forEach(function(cat) { console.log(cat); res.write("" + p.name + "
"); }); res.write("
"); resolve(); }) }); } };