question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

get TypeError: callbackFn is not a function when using decodeFromVideoDevice()

See original GitHub issue

I’m on version 0.18.2 of the library, trying to use this library according to the code in this example, https://github.com/zxing-js/library/blob/master/docs/examples/multi-camera/index.html. Somehow, got the following error in the console.

TypeError: callbackFn is not a function

However, when replacing decodeFromVideoDevice() with decodeOnceFromVideoDevice(), everything is working fine.

Desktop (please complete the following information):

  • OS: iOS 10.15.7
  • Browser: Firefox
  • Version: 81.0.1 (64-bit)

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
ratiwcommented, Oct 26, 2020

Oh, sorry. That was my bad. I didn’t notice the API difference between decodeOnceFromVideoDevice() and decodeFromVideoDevice().

After calling decodeFromVideoDevice() with the callback function in the 3rd parameter, it is now working as expected.

Sorry for the trouble and really thank you for pointing me out.

Cheers,

0reactions
odahcamcommented, Oct 25, 2020

Please make sure you are correctly using the method:

            this.scanner.decodeFromVideoDevice(id, 'video', (result, err) => {
              if (err) {
                if (err && !(err instanceof ZXing.NotFoundException)) {
                  console.log('selectCamera:', err)
                }
                return;
              } // else
              this.scanSuccess(result);
            })

If you do not pass the third argument you will indeed get the callbackFn error. ImageCapture is used to check if torch is available, I think it’s better to surround that block with a try-catch and ignore this error, because browsers that doesn’t support full webrtc will throw this error and probably break code execution.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Callback is not a function - Stack Overflow
I am trying to retrieve a json object to use it in another module, but I have a problem with callback ...
Read more >
TypeError: "x" is not a function - JavaScript
The JavaScript exception "is not a function" occurs when there was an attempt to call a value from a function, but the value...
Read more >
Uncaught TypeError | Is Not A Function | Solution - YouTube
Have you encountered an error like:- Uncaught TypeError - Some selector is not a function - jQuery is not a function - owlCarousel...
Read more >
How to fix "Uncaught TypeError: x is not a function" in JavaScript
JS Casts 01 - How to fix "Uncaught TypeError : x is not a function " in JavaScript.Visit https://javascriptcasts.com/episodes/01 for a summary ...
Read more >
TypeError: callback is not a function in JavaScript | bobbyhadz
The "callback is not a function" error occurs when we define a callback parameter to a function, but invoke the function without passing...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found