In official doc, there is some sample code:
var req = http.request(options, function(res) {
console.log(\'STATUS: \' + res.statusCode);
console.log(\'HEADERS
As far as I'm aware, it's no different than addListener
. There is some documentation on the event here: http://nodejs.org/docs/latest/api/events.html#emitter.on Both on
and addListener
are documented under the same heading. They have the same effect;
server.on('connection', function(stream) {
console.log('someone connected!');
});
server.addListener('connection', function(stream) {
console.log('someone connected!');
});