我不确定问题是什么,但我想我必须使这个异步或基于promise(idk how)。我只是想通过呼叫传递给http服务器上的资源。 有人可以帮忙吗?将http.request或superagent的值传递给http.createServer NodeJs
HTTP请求或SuperAgent将值传递给下面的函数。如何将此发送给http.createserver?
function receiveCallback(link) {
console.log(link);
//this works fine, echos the LINK we want to 302 to
}
如何通过链接到http服务器?
http.createServer(function (req, res) {
res.writeHead(302, {'Location': link});
res.end();
}).listen('8080');
例如。用户打开domain.com/test? somevar
somevar发送到的SuperAgent然后产生一个链接
如何302用户链接
可以调用'receiveCallback()'多次,或只是在开始一次? – gregnr
多次。基本上服务器将url路径传递给superagent,然后输出一个我希望服务器到302的链接。 – JsEveryDay
几乎像这样https://stackoverflow.com/questions/14243100/response-writehead-and-response-end-in-nodejs但如何将我的链接/回调插入函数。 – JsEveryDay