pdupavillon / express-recaptcha

Implementation of google recaptcha v2 & V3 solutions for express.js
MIT License
128 stars 21 forks source link

Uncaught Exceptions #34

Closed 1Map closed 5 years ago

1Map commented 5 years ago

Hi, I am using your package and what I can see is that it injects the recaptcha code on the web page (which works wonderful), example:

...., {action: 'homepage'})
.then(recaptchaReady);

Except when an error might occur due to, for example, a timeout (slow connection). In this case, the Promise code above does not handle the exception and the browser gives an error like:

Uncaught (in promise) Timeout Promise.then (async)

How would I handle exceptions in the Promise (auto-generated by your package)?

For example:

...., {action: 'homepage'})
.then(recaptchaReady)
.catch((err) => {
  // Handle any error that occurred in any of the previous
  // promises in the chain.
});
pdupavillon commented 5 years ago

@1Map thanks for using this package! AFAIK, I'm not using any promise in this package, and none are auto-generated. I suggest you, to take a look at the example folder to see how to implement it.