mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-06-01 19:45:48 +08:00
20 lines
438 B
TypeScript
20 lines
438 B
TypeScript
import * as reCAPTCHA from 'recaptcha2';
|
|
|
|
const recaptcha = new reCAPTCHA({
|
|
siteKey: 'your-site-key',
|
|
secretKey: 'your-secret-key'
|
|
});
|
|
|
|
const key = 'invalid';
|
|
|
|
recaptcha.validate(key)
|
|
.then(() => {
|
|
// validated and secure
|
|
})
|
|
.catch((errorCodes) => {
|
|
// translate error codes to human readable text
|
|
const message = recaptcha.translateErrors(errorCodes);
|
|
});
|
|
|
|
const formSnippet = recaptcha.formElement('recaptcha');
|