kayaknya pas liburan semester nanti pengen coba mendalami lagi belajar PHP.

kemaren sempat coba belajar JavaScript/NodeJS malah stuck dan malah bikin nggak mood ngelanjutinnya lagi

😩

Reply to this note

Please Login to reply.

Discussion

Stuck di mana?

Kalau hello world masih gampang.

Load modul / package tinggal panggil `require("http")` (untuk load modul http contohnya)

Contoh server HTTP basic:

```

// Variabel const: Variabel yang tidak bisa diubah

const http = require("http");

const server = http.createServer();

server.on("request", (req, res) => {

// Halo

res.end("Halo!");

});

// Listen di port 3000

server.listen(3000);

```

Langsung jalankan dengan command `node index.js` (jika kode disimpan di index.js), lalu buka browser, ke http://localhost:3000