Let's break down our HTTP server code to see what's really going on. First, we require the http package so we can access the HTTP module's methods:
const http = require('http');
Next, we use the createServer method to create a server instance that listens to incoming requests. Inside it, we pass in a request handler function that takes a req and res parameters.
The req parameter is an object containing information about the request, such as its origin IP, URL, protocol, body payload (if any), and so on. The res object provides methods that help you prepare the response message to ...