Javascript in browser error
b4oz opened this issue · comments
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>
set constructor like this
new AwesomeQR.AwesomeQR({