title: how to use async await with https post request
body: <p>I am finding way out to use async / await with https post. Please help me out. I have posted my https post code snippet below.how do I use async await with this. </p>
  
  <pre><code>const https = require('https')
  
  const data = JSON.stringify({
    todo: 'Buy the milk'
  })
  
  const options = {
    hostname: 'flaviocopes.com',
    port: 443,
    path: '/todos',
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'Content-Length': data.length
    }
  }
  
  const req = https.request(options, (res) =&gt; {
    console.log(`statusCode: ${res.statusCode}`)
  
    res.on('data', (d) =&gt; {
      process.stdout.write(d)
    })
  })
  
  req.on('error', (error) =&gt; {
    console.error(error)
  })
  
  req.write(data)
  req.end()
  </code></pre>