Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Javascript in browser error #50

Open
b4oz opened this issue Jan 27, 2021 · 1 comment
Open

Javascript in browser error #50

b4oz opened this issue Jan 27, 2021 · 1 comment

Comments

@b4oz
Copy link

b4oz commented Jan 27, 2021

Using the example set out in the READ.me gives me the following error in Chrome browser:

Uncaught TypeError: AwesomeQR is not a constructor
at FileReader.reader.onload (jsqr.html:23)

What am I doing wrong?

I also had to add (dataURL) => '') instead of (dataURL) =>) to have the page load simply to test.

HTML Code is:

<script src="dist/awesome-qr.js"></script>
<body>
  <input type="file" onchange="previewFile()"><br>
  <img  src="" height="200" alt="Image preview...">
<script>

var background;

const preview = document.querySelector('img');
var reader = new FileReader();

reader.onload = function () {
  preview.src = this.result;
  background = this.result;

  new AwesomeQR({
    text: "AwesomeQR by Makito - Awesome, right now.",
    size: 500,
    backgroundImage: background,
  }).draw().then((dataURL) => );
};

function previewFile() {
  const file = document.querySelector('input[type=file]').files[0];

  if (file) {
    reader.readAsDataURL(file);
  }
}


</script>
</body>
@ibnux
Copy link

ibnux commented Apr 17, 2021

set constructor like this

new AwesomeQR.AwesomeQR({

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants