我的代码分为两个文件:router.js
和work.js
以下是work.js
的代码:
getThumbnailItems = function(callback, res) {
fs.readdir(this.thumbnailPath, function(err, files) {
callback(files, res);
}
});
}
以下是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)
}
我在getThumbnails
中使用回调来呈现home
视图。但是错误"Can't set headers after they are sent"
不断被抛出。有谁知道这里发生了什么?