Because without end, the response is never finished and the request hangs. The client waits indefinitely. Always call response.end after sending the body, even if the body is empty.
The Node.js http Module Explained: Requests, Responses, and Servers
Why must I call response.end in a Node.js server?
The answer
More FAQs in The Node.js http Module Explained: Requests, Responses, and Servers
http.createServer for creating servers, http.request for making requests, and the IncomingMessage (request) and ServerResponse (response) objects. It is the foundation that Express and other frameworks build on.
The request body is a readable stream. Listen to 'data' events for chunks and 'end' for completion. For JSON, concatenate chunks and JSON.parse the result. This is how Express body parsing works under the hood.
Yes. The request body is a readable stream, and the response is a writable stream. This means large bodies are processed in chunks, keeping memory low, which is essential for large uploads or downloads.
Still have questions?
Browse all our FAQs or reach out to our support team
Want to upskill yourself?
Your learning library
Small steps. Big possibilities.
Find your next course. Build something great.