如何redirect到一个URL,并在节点js发出一个post请求?

基本上会发生什么是我的angular度页面将发表请求我的快递/节点js应用程序。

我想表示接收从angular度redirect到另一个URL,并且还redirect,要POST数据到该网页的发布请求。 我将如何在节点res.redirect("")使用res.redirect("")来发布一些数据。

节点js代码:

 app.post('/ur-book',function(req,res){ var data=...; res.redirect('/abcd'); }); 

我想在/ abcd上发布数据并redirect到它。

其他的url将不会在我的节点应用程序。 它将在不同的网站上。

简单的方法是创build一个处理/ abcd请求的函数,并像这样从/ ur-book调用该函数

 function handleAbcd(req, res) { console.log(req.myData); // output will be undefined if it's not comming from /ur-book res.json({}); } app.post('/abcd',handleAbcd); app.post('/ur-book',function(req,res){ // if you need to add some data you can add them to req.body or even your own for example req.myData req.myData = 'hello'; handleAbcd(req, res); });