zxpsuper / qrcode-with-logos

A plugin for generating QR codes with a logo and styling.
https://zxpsuper.github.io/qrcode-with-logos
MIT License
137 stars 41 forks source link

`getImage()` promise never gets resolved #37

Closed kevinkosterr closed 2 months ago

kevinkosterr commented 2 months ago

So I've just found out toImage() is deprecated, however when trying to switch to getImage() the code never reaches the .then() block. Thus, the promise never gets resolved.

So given the example in the docs:

let qrcode = new QrCodeWithLogo({
  canvas: document.getElementById("canvas"),
  content: "https://github.com/zxpsuper",
  width: 380,
  image: document.getElementById("image"),
  logo: {
    src: "https://avatars1.githubusercontent.com/u/28730619?s=460&v=4"
  }
});

qrcode.getImage().then(image => {
  // code execution never gets here
});
zxpsuper commented 2 months ago

I find it. Add the default options and it will be normal to use. image I will fix it in next version! Thank you !

kevinkosterr commented 2 months ago

@zxpsuper awesome. Perhaps it would be a good idea to reject the Promise for getImage() whenever an issue occurs?

caprica commented 1 month ago

Same for getCanvas() in fact?

zxpsuper commented 1 month ago

@zxpsuper awesome. Perhaps it would be a good idea to reject the Promise for getImage() whenever an issue occurs?

There is global error catching that you can use onError to deal with it.