Last active
July 3, 2019 18:53
-
-
Save crazy4groovy/e1030706eb5b708872f96fad663cba0e to your computer and use it in GitHub Desktop.
Check Google reCaptcha response
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const https = require('https') | |
async function checkReCaptcha(secret, response) { | |
const url = `https://www.google.com/recaptcha/api/siteverify?secret=${secret}&response=${response}` | |
return new Promise((resolve, reject) => { | |
https | |
.get(url, (res) => { | |
let rawData = '' | |
res.on('data', (data) => { rawData += data }) | |
res.on('end', () => resolve(JSON.parse(rawData))) | |
}) | |
.on('error', reject) | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment