serverresponse 1


const server = http.createServer((req, res) => {
  //res is an http.ServerResponse object

Here is what the above code is Doing:
1. We’re creating a server using the http module’s createServer() method.
2. The createServer() method takes a callback function as an argument.
3. The callback function takes two arguments: req and res.
4. The req argument represents the HTTP request and has properties for the request query string, parameters, body, HTTP headers, and so on.
5. The res argument represents the HTTP response that the Express app sends when it receives an HTTP request.
6. The res object has properties for setting HTTP headers and sending data.
7. The res object has a method called send() for sending data in the response.

Similar Posts