私のコードは2つのファイルにあります: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"がスローされ続けます。ここで何が起こっているか知っている人はいますか?