youtube-po-token-generator/lib/utils.js
2024-08-06 10:03:42 +08:00

22 lines
467 B
JavaScript

const https = require('https')
const { headers, url } = require('./consts')
const download = (url) => new Promise((resolve, reject) => {
https.get(url, { headers }, (res) => {
let data = ''
res.on('data', (chunk) => {
data += chunk
})
res.on('end', () => {
resolve(data)
})
}).on('error', (err) => {
reject(err)
})
})
const formatError = (err) => err.message || err.toString()
module.exports = { download, formatError }