imageUrlToBase64
Script
v4
Fork
1
2
3
4
5
6
7
import
{
Buffer
}
from
"node:buffer"
;
export
async
function
imageUrlToBase64
(
res
:
Response
)
{
// From https://stackoverflow.com/a/60321567
const
buffer
=
Buffer
.
from
(
await
res
.
arrayBuffer
(
)
)
;
return
buffer
.
toString
(
"base64"
)
;
}