【发布时间】:2016-03-22 00:19:32
【问题描述】:
我有这条似乎拒绝渲染翡翠模板的快速路线。当我输入错误的玉模板字符串时,我通常找不到正在呈现给浏览器的文件。
但是当我选择正确的时候,什么都没有发生......
此外,当我在res.render() 之后添加res.status(500).send() 时,我最终会收到 500 错误或我选择放入其中的任何其他代码。
这是怎么回事?
app.post('/stuff/new', function (req,res){
Stuff.findById(req.body.booking_id, function(err, stuff){
if(err){ console.log("Err", err)}
else if (booking) {
Thungs.findById(req.body.user_id, function(err, thung){
user.stuff.push(req.body.things);
user.save();
});
Thingers.findById(req.body.center_id, function(err, thinger){
center.stuff.push(req.body.things);
center.save();
});
stuff.prop = 'thing';
stuff.save(function(err, result){
if (err) { console.err("err", err) }
else {
res.render('booking/thank_you', {
url: req.url,
id: "thank_you"
}, function(err, html){
if (err) { console.err("ERR", err) }
else {
res.send(html);
}
});
res.status(500).send();
}
});
}
})
});
【问题讨论】:
-
会不会是因为我使用 $.ajax 来调用这个路由?
-
你设置快递用jade了吗?
-
你能检查 chrome-dev 工具来检查服务器的响应吗? (首先删除
res.status(500)...)。另外,您的控制台中是否显示错误?
标签: javascript node.js express