Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/40.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/performance/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js 使用res.location和res.render_Node.js_Express - Fatal编程技术网

Node.js 使用res.location和res.render

Node.js 使用res.location和res.render,node.js,express,Node.js,Express,我让用户使用POST to/upload提交一个文件,然后我希望浏览器呈现index.mustache,并告诉浏览器位置是/。我尝试使用以下代码(在multer的onFileUploadComplete中)执行此操作: 它呈现索引,但浏览器将位置显示为/upload,而不是我想要的/。我做错了什么?(回答我自己的问题) 通过使用res.redirect('/')并将我的{options:'whatever'}逻辑放在别处,我能够解决我的问题。(回答我自己的问题) 通过使用res.redirect

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

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

(回答我自己的问题)

通过使用
res.redirect('/')
并将我的
{options:'whatever'}
逻辑放在别处,我能够解决我的问题。

(回答我自己的问题)

通过使用
res.redirect('/')
并将我的
{options:'whatever'}
逻辑放在别处,我能够解决我的问题

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