Created
September 8, 2020 03:07
-
-
Save mobsense/dc4acae861f36c0e396b71265f3610eb to your computer and use it in GitHub Desktop.
Async HTTP for Lambda
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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