我是node.js和javascript的新手。在node.js中进行一些计算后,我想使用一个函数来重定向用户的浏览器。
这是我的代码
const express = require('express');
const app = express();
app.get('/number/:num', (req, res) =>{
var user_num = req.params.num;
user_num = user_num + 10; // here, I do some calculations like this
go(user_num)
});
function go(nu){
var number_2 = nu + "1"; // some calculations here too.
//here I want to redirect user to a url with the number_2 on the url.
// www.mydomain.com/number/?id=number_2 <==== LIKE THIS
}
app.listen(3000, () => console.log('listening to port 3000...'));
有什么方法可以像这样重定向用户?请帮忙。谢谢
相关分类