My code is in two files: router.js and work.js
Here is the code for work.js:
getThumbnailItems = function(callback, res) {
fs.readdir(this.thumbnailPath, function(err, files) {
callback(files, res);
}
});
}
Here is where the method is called in router.js:
exports.home = function(req, res) {
getThumbnailItems(function(items) {
console.log(items);
if (res) {
res.render("home", {title: "The Work Speaks For Itself", items: items});
}
}, res)
}
I am using a callback in getThumbnails to render the home view. But an error "Can't set headers after they are sent" keeps getting thrown. Does anyone know what is going on here?