router.get('/newsfeed', (req, res, next) => {
var sql = 'select title, image, article from database';
var request = new Request(sql, function(err) {
if (err) {
console.log(err);
}
});
console.log("working");
request.on('row', function(columns) {
var t_title = columns[0].value;
var i_image = columns[1].value;
var a_article = columns[2].value;
console.log("after column");
res.render('newsfeed', { title: t_title, image: i_image, article: a_article });
console.log("after render");
});
console.log("not here");
conn.execSql(request);
console.log("after request")
});
我似乎无法找到如何阻止它进入consol.log(“渲染后”),如下所示:
working
not here
after request
after column
after render
after column
after render
然后它与throw错误崩溃任何帮助都会很棒
答案 0 :(得分:1)
row
事件每行触发一次。
您只能发送一次响应,因此当您尝试向第二行发送第二个响应时会出现该错误。