2014-02-07 140 views
0

這是我發送http請求的代碼。爲什麼我的請求沒有結束,有什麼不對嗎?在節點Js中結束HTTP請求

var req = http.request(options, function(res) { 
     res.setEncoding('utf8'); 
     res.on('data', function(chunk) { 
      console.log('Response: ' + chunk); 
     }); 
    }); 

    req.write(uid); 
    req.end();   //i think this line will end the requset, but not. 

感謝您的回答傢伙。

回答

0

我發現我錯過結束與res.end();

var req = http.request(options, function(res) { 
     res.setEncoding('utf8'); 
     res.on('data', function(chunk) { 
     console.log('Response: ' + chunk); 
     }); 
    }); 

    req.write(uid); 
    req.end(); 
    res.end(); 
響應