Using res.location with res.render



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

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

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

(回答自己的问题)

我能够通过使用res.redirect('/')并将我的{options: 'whatever'}逻辑放在其他地方来解决我的情况。

最新更新