Node.js Basics
The Essential Knowledge We Need
How the Web Works

HTTP, HTTPS

Creating a Node Server
Core Modules

- require: importing file
- ‘./’ stands for local file, otherwise, it will look for the global module
- createServer() takes a requestListner, a function that executes for every incoming request, as an argument
const http = require('http');http.createServer((req,res) => {
console.log(req);
});
After running this by using command,
node app.js
Nothing happens 😟!!
Why? We didn’t send a request to the server, and we don’t even know where the server is.
How do we reach the server? This creates the server method actually returns the server.
Now we store them in the variable:
const http = require('http');const server = http.createServer((req,res) => {
console.log(req);
});server.listen(3000);
Node.js will keep this running to listen for incoming request. We then put the port number 300 to be local.
❓ See what happens on the web browser by entering localhost:3000.
✔️ Nothing since we haven’t set to return any html, but it’s still running, waiting for the request!!