Spaces:
Building
Building
File size: 484 Bytes
5ae7e18 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
const https = require('https')
module.exports = (url, filter = false) => {
return new Promise((resolve, reject) => {
https.get(url, (res) => {
if (filter && filter(res.headers)) {
resolve(Buffer.concat([]))
}
const chunks = []
res.on('error', (err) => {
reject(err)
})
res.on('data', (chunk) => {
chunks.push(chunk)
})
res.on('end', () => {
resolve(Buffer.concat(chunks))
})
})
})
}
|