我有以下内容:
var myObject={name:"name"};
var options={
hostname:'www.google.com',
port:80,
method:'GET'
};
var req=http.request(options,function(res){
res.on('data', function (chunk) {
myObject.serverResponse=chunk;
console.log(myObject);
});
});
req.on('error', function(e) {
console.log('problem with request: ' + e.message);
});
req.end();
在控制台中我没有得到 serverResponse 键/值对。我刚刚收到原始对象。我哪里错了?