Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Asynchronous HTTPS Request Module
let https = require('https')
module.exports = (url, options = {}) => {
return new Promise((resolve, reject) => {
https.get(url, options, response => {
let data = ''
response.on('data', chunk => [
data += chunk
])
response.on('end', () => {
resolve(JSON.parse(data))
})
response.on('error', reject)
})
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment