0

我的代码在两个文件中:router.jswork.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"但是不断抛出错误。有谁知道这里发生了什么?

4

0 回答 0