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");
}
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Comments
Nobody has commented on this val yet: be the first!
October 23, 2023