Skip to content

Latest commit

 

History

History
35 lines (27 loc) · 916 Bytes

File metadata and controls

35 lines (27 loc) · 916 Bytes
  • options {Object | string | URL} Accepts the same options as [https.request()][], with the method always set to GET.
  • callback {Function}

Like [http.get()][] but for HTTPS.

options can be an object, a string, or a [URL][] object. If options is a string, it is automatically parsed with [url.parse()][]. If it is a [URL][] object, it will be automatically converted to an ordinary options object.

Example:

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);
});