Courses / Node.js
2. req and res objects (IncomingMessage & ServerResponse)
Understand the properties and methods on Node's request and response objects used to read requests and write responses.
JavaScript (Node.js)
req and res objects (IncomingMessage & ServerResponse)
Objects provided by Node's HTTP server to read the incoming request and to send back a response.
"I need to read what the client sent and write the right HTTP reply."
req is a readable stream-like IncomingMessage carrying headers, URL, method, and body; res is a ServerResponse used to set headers/status and send the body. Together they let you handle HTTP requests and craft responses.
"I need to read what the client sent and write the right HTTP reply."
req is a readable stream-like IncomingMessage carrying headers, URL, method, and body; res is a ServerResponse used to set headers/status and send the body. Together they let you handle HTTP requests and craft responses.