Node.js
/Intermediate
Request & Response Lifecycle
Definition
The end-to-end journey of a network call, from the client establishing a connection, to the server parsing the request, executing business logic, and terminating the connection by sending a response.
Explain Like I'm New
A conversation. 1. Client calls the server: 'Hello, here is my cookie (Headers) and here is a photo (Body).' 2. Server parses the data. 3. Server talks to the database. 4. Server replies: 'Here is status code 201 (Headers) and a success message (Body).' 5. The server hangs up the phone (ends the connection).
Real World Example
If your code forgets to call `response.end()` (or `res.send()` in Express), the server literally never hangs up the phone. The user's browser will show a spinning loading wheel forever until it eventually times out.
Common Use Cases
- •Debugging infinite loading spinners
- •Parsing JSON bodies
Interactive Example
Loading...
Console output will appear here...
Interview Questions
basic
- What happens if you never call `.end()` on a response?
intermediate
- Can you send headers AFTER you have already sent the body?