0
我試圖訪問遠程URL,只是其輸出,這個工程:當我嘗試訪問http.get響應時,爲什麼我的應用程序中斷?
app.get('/', function (req, res) {
http.get({
hostname: 'localhost',
port: 80,
path: '/',
agent: false // create a new agent just for this one request
}, (response) => {
console.log('foo');
});
});
但是當我做:
app.get('/', function (req, res) {
http.get({
hostname: 'localhost',
port: 80,
path: '/',
agent: false // create a new agent just for this one request
}, (response) => {
console.log(response);
});
});
我得到一個Unable to load the webpage because the server sent no data.
我也試過res.send(response)
我不確定我的設置,但是如果我編寫本地主機:80,我得到我正在嘗試登錄的頁面
在瀏覽器的開發工具中檢查請求 - 服務器響應是什麼樣的? – CBroe