radames's picture
first
18cd77b
raw
history blame contribute delete
621 Bytes
function blobToBase64(blob: Blob): Promise<string> {
return new Promise((resolve) => {
const reader = new FileReader();
reader.onloadend = () => resolve(reader.result as string);
reader.readAsDataURL(blob);
});
}
export const timeFormater = new Intl.DateTimeFormat('en-US', {
day: 'numeric',
month: 'short',
hour: 'numeric',
minute: 'numeric'
}).format;
export async function fetchImageBase64(url: string): Promise<string> {
const response = await fetch(url);
const blob = await response.blob();
const base64 = await blobToBase64(blob);
return base64;
}