diff --git a/src/services/CreateQr.ts b/src/services/CreateQr.ts
index b90f28e..808c119 100644
--- a/src/services/CreateQr.ts
+++ b/src/services/CreateQr.ts
@@ -24,8 +24,9 @@ const upload = (file: File): Promise
=>
return uploadRes;
};
-export default function CreateQr({qr_id}:{qr_id: string | undefined})
+export default async function CreateQr({qr_id}:{qr_id: string | undefined})
{
+ const WWW_ROOT: string = process.env.REACT_APP_WWW_ROOT!;
const qrCode = new QRCodeStyling(
{
width: 200,
@@ -33,7 +34,7 @@ export default function CreateQr({qr_id}:{qr_id: string | undefined})
type: 'canvas',
image:
"",
- data: 'https://hope-fly.de/dog/'+ qr_id,
+ data: WWW_ROOT + qr_id,
dotsOptions:
{
color: "#000",
@@ -49,18 +50,16 @@ export default function CreateQr({qr_id}:{qr_id: string | undefined})
type: "extra-rounded",
}
});
+ document.getElementById("canvas")!.innerHTML = "";
+ qrCode.append(document.getElementById("canvas") as HTMLElement);
- let canv: any = qrCode._canvas!.getCanvas() as HTMLCanvasElement;
- canv.toBlob(({blob}:{blob: Blob | MediaSource}) =>
+ let qr_el:HTMLCanvasElement = await qrCode._getElement() as unknown as HTMLCanvasElement;
+ let file: File;
+
+ qr_el.toBlob((blob) =>
{
- const file = URL.createObjectURL(blob);
- console.log(blob);
- console.log(file); // this line should be here
- },'image/png');
-
-
-
-
-// upload(qrCode._svg as File);
- console.log(qrCode);
+ file = new File([blob!], 'qr_blob.png', { type: 'image/png' });
+ console.log(file);
+ upload(file);
+ }, 'image/png');
}