//DB query const sql = require('../utils/sql'); //file IO const utils = require('../utils/utils.js'); /** * Renders all posts in a single category * * @param resultURL * @returns {*} */ const renderPosts = function(resultURL) { const splitURL = resultURL.split("/"); if(splitURL.length >= 3) { return new Promise(function(resolve, reject) { sql.getPostsFromCategory(splitURL[2]).then(function(posts) { var promises = []; posts.forEach(function(p) { promises.push(new Promise(function(res, rej) { require("../posts/singlePost.js") .renderPreview(p).then(function(html) { res(html); }).catch(function(error) { rej(error); }) })); }); Promise.all(promises).then(function(content) { resolve("