https.get()

https.get(options, callback)

Like http.get() but for HTTPS.

options can be an object or a string. If options is a string, it is automatically parsed with url.parse().

Example:

1
2
3
4
5
6
7
8
9
10
11
12
13
const https = require('https');
 
https.get('https://encrypted.google.com/', (res) => {
  console.log('statusCode: ', res.statusCode);
  console.log('headers: ', res.headers);
 
  res.on('data', (d) => {
    process.stdout.write(d);
  });
 
}).on('error', (e) => {
  console.error(e);
});
doc_Nodejs
2025-01-10 15:47:30
Comments
Leave a Comment

Please login to continue.