'How to verify user based on reCAPTCHA user response and secret key in react.js?

When reading the documentation, the following methods of verifying the user are shown: For web users, you can get the user’s response token in one of three ways:

g-recaptcha-response POST parameter when the user submits the form on your site

grecaptcha.getResponse(opt_widget_id) after the user completes the reCAPTCHA challenge

As a string argument to your callback function if data-callback is specified in either the g-recaptcha tag attribute or the callback parameter in the grecaptcha.render method

How would I do any of those three in react.js, given that I have a token and the secret key?

When visiting the url from which the json is to be gathered, the following is found:

{ success: true, score: 0.9, domain: localhost, }

How would I get the score in this case?

I have tried the following:

const response = await fetch(url);
var data = await response.json();

This produces a typeerror however, (failed to fetch).



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source