-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstep-2.js
More file actions
31 lines (20 loc) · 677 Bytes
/
Copy pathstep-2.js
File metadata and controls
31 lines (20 loc) · 677 Bytes
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
// use a buffering technique to append each chunk of data to a variable as it is received, and then console.log the data once all of the data has been received
var https = require('https');
function getAndPrintHTML () {
var requestOptions = {
host: 'sytantris.github.io',
path: '/http-examples/step2.html'
};
https.get(requestOptions, function (response) {
response.setEncoding('utf8');
let bufferedOutput = "";
response.on('data', function (data) {
bufferedOutput += data
console.log(bufferedOutput);
});
response.on('end', function() {
console.log('Response stream complete.');
});
});
}
getAndPrintHTML();