fix: qr base64 > qr uri
This commit is contained in:
+12
-2
@@ -25,8 +25,18 @@ export async function getAddressInfoBulk(addresses: string[]): Promise<Record<st
|
||||
return res.json();
|
||||
}
|
||||
|
||||
export function getQrUrl(text: string): string {
|
||||
return `${API}/invoice/qr/${encodeURIComponent(text)}`;
|
||||
export async function fetchQrBase64(text: string): Promise<string> {
|
||||
const url = `${API}/invoice/qr/${encodeURIComponent(text)}`;
|
||||
try {
|
||||
const res = await fetch(url);
|
||||
if (!res.ok) return url;
|
||||
const buf = await res.arrayBuffer();
|
||||
const type = res.headers.get("content-type") || "image/png";
|
||||
const b64 = Buffer.from(buf).toString("base64");
|
||||
return `data:${type};base64,${b64}`;
|
||||
} catch {
|
||||
return url;
|
||||
}
|
||||
}
|
||||
|
||||
export async function getAvailableCoins(): Promise<string[]> {
|
||||
|
||||
Reference in New Issue
Block a user