What is the difference between request.on ('error') and response.on ('error')

when creating http.request there are 2 events that cause errors: request.on('error') and response.on('error') .

I see no difference because both errors come from the web server.

what's the difference between thisError and thatError ?

 var request = http.request({hostname:"example.com"}, function(response){ response.on('error', function(thisError){ //what the difference between thisError <<<<<< }); }); request.on('error, function(thatError){ //and thatError <<<<< }); 
+5
source share
1 answer

During the request, you resolve the name, establish a connection, send a bunch of data, and each task can lead to an error.

When you receive data through a response object, as an example, the other end may unexpectedly close the connection.

These errors are different, and they must belong to the correct structure, in this case, respectively, request and response.

+5
source

Source: https://habr.com/ru/post/1239377/


All Articles