我不確定問題是什麼,但我想我必須使這個異步或基於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