Skip to content

Instantly share code, notes, and snippets.

@mobsense
Created September 8, 2020 03:07
Show Gist options
  • Save mobsense/dc4acae861f36c0e396b71265f3610eb to your computer and use it in GitHub Desktop.
Save mobsense/dc4acae861f36c0e396b71265f3610eb to your computer and use it in GitHub Desktop.
Async HTTP for Lambda
const https = require('https')
const URL = require('url')
async function request(url, data) {
return new Promise((resolve, reject) => {
let req = https.request(URL.parse(url), function (res) {
let body = ''
res.on('data', (chunk) => { body += chunk })
res.on('end', () => { resolve(body) })
})
req.write(data)
req.end()
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment