title: async / await for Node.js https.get
body: <p>I'm trying to simplify code with async / await</p>
  <p>But have problems making <code>https.get</code> with async / await structure.</p>
  <p>I am aware of how to do this with third-party modules but prefer the native node.js <code>https</code> module.</p>
  <p>Below code doesn't work for me:</p>
  <pre class="lang-js prettyprint-override"><code>async function get_page() {
  
      const https = require('https')
      const url = 'https://example.com'
  
      const util = require('util')
      const https_get = util.promisify(https.get)
  
      const data = await https_get(url)
  
      do_awesome_things_with_data(data)
  }
  </code></pre>
  <p>This code working fine:</p>
  <pre class="lang-js prettyprint-override"><code>function get_page() {
  
      const https = require('https')
      const url = 'https://example.com'
  
      let data = ''
  
      https.get(url, res =&gt; {
  
          res.on('data', chunk =&gt; { data += chunk }) 
  
          res.on('end', () =&gt; {
  
             do_awesome_things_with_data(data)
  
          })
      }) 
  }
  </code></pre>