You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
12 lines
356 B
12 lines
356 B
import got from 'got'
|
|
|
|
export default async function (iconUrl) {
|
|
return got(iconUrl).then(res => {
|
|
const type = res.headers['content-type']
|
|
if (!type!.startsWith('image')) { return }
|
|
|
|
const base64 = Buffer.from(res.body).toString('base64')
|
|
const encoded = `data:${type};base64,${base64}`
|
|
return encoded
|
|
}).catch(err => undefined)
|
|
}
|
|
|