-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhttp-example.js
More file actions
33 lines (29 loc) · 1.05 KB
/
Copy pathhttp-example.js
File metadata and controls
33 lines (29 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// const { request, get } = require("https");
const { request, get } = require("node:https"); // these are build in core node modules, because we add extra perfix
// ES6 way
// import http from "node:http"
const req = request("https://www.google.com", (res) => {
res.on("data", (chunk) => {
console.log("====================================");
console.log(`Data Chunk ${chunk}`);
console.log("====================================");
});
res.on("end", () => {
console.log("====================================");
console.log("End of response");
console.log("====================================");
});
});
get("https://www.google.com", (res) => {
res.on("data", (chunk) => {
console.log("====================================");
console.log(`Data Chunk 2 ${chunk}`);
console.log("====================================");
});
res.on("end", () => {
console.log("====================================");
console.log("End of response 2");
console.log("====================================");
});
});
req.end();