Skip to content

Instantly share code, notes, and snippets.

@miguelmota
Last active April 19, 2018 02:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save miguelmota/e056396fd65d81e28cbd817d90046b8d to your computer and use it in GitHub Desktop.
Save miguelmota/e056396fd65d81e28cbd817d90046b8d to your computer and use it in GitHub Desktop.
Node.js Google reCAPTCHA verify request
import request from 'request'
export async function verify(captchaResponse) {
return new Promise((resolve, reject) => {
request.post('https://www.google.com/recaptcha/api/siteverify', {
form: {
secret: process.env.RECAPTCHA_SECRET_KEY,
response: captchaResponse,
}
}, (err, resp, body) => {
if (err) return reject(err)
const result = JSON.parse(body)
resolve(result.success)
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment