Join our book community on Discord
https://packt.link/EarlyAccess
The foundation of server-side web development is the ability to receive HTTP requests from clients and generate responses. In this chapter, I introduce the Node.js API for creating HTTP servers and explain how it can be used to receive and respond to requests. Table 5.1 puts the Node.js HTTP API in context.
Table 5.1. Putting the Node.js API in contextQuestion | Answer |
What is it? | The http and https modules contain the functions and classes required to create HTTP and HTTPS servers, receive requests, and generate responses. |
Why is it useful? | Receiving and responding to HTTP requests is the core feature of server-side web application development. |
How is it used? | Servers are created with the createServer function, which emits events when requests are received. Callback functions are invoked to handle the request and generate a response. |
Are there any pitfalls or limitations? | Handler functions can become complex... |