猿问

如何将用户的浏览器重定向到外部链接

我是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...'));

有什么方法可以像这样重定向用户?请帮忙。谢谢


弑天下
浏览 198回答 1
1回答
随时随地看视频慕课网APP

相关分类

JavaScript
我要回答