使用res.location和res.render

时间:2015-07-17 14:58:28

标签: node.js express

我让用户使用POST向/upload提交文件,然后我希望浏览器呈现index.mustache并告诉浏览器该位置为/。我尝试使用以下代码执行此操作(在multer' onFileUploadComplete中):

res.location('/');
res.render('index', {options: 'whatever'});

它呈现index,但浏览器会根据需要将位置显示为/upload,而不是/。我做错了什么?

1 个答案:

答案 0 :(得分:0)

(回答我自己的问题)

我能够使用res.redirect('/')并将我的{options: 'whatever'}逻辑放在其他位置来解决我的问题。