Built-in, No Framework Required
Every popular Node.js web framework — Express, Fastify, Koa — is ultimately built on top of the core http module. Understanding it directly helps demystify what those frameworks are actually doing underneath their APIs.
Making an HTTP Request
Console Output
Click “Run” to see the console output here.
fetch() Is Also Available
Modern Node.js versions include a global fetch() (the same API browsers use), which is usually more convenient than the raw http/https modules for making outgoing requests. The http module remains essential for building servers.
A Minimal HTTP Server
Console Output
Click “Run” to see the console output here.
Request & Response Basics
| Object | Useful Properties |
|---|---|
| req | req.method, req.url, req.headers |
| res | res.writeHead(status, headers), res.write(chunk), res.end(chunk) |
Why Frameworks Exist
The raw http module has no built-in routing, no request body parsing, and no middleware system — every one of those is manually written on top. This is exactly what frameworks like Express add, which is why the next lessons introduce it.
Best Practice
Building at least one tiny server with the raw http module is a valuable exercise, even though you'll use a framework in practice — it makes concepts like routing, middleware, and body parsing feel far less magical once you see what they're built on.