0

Here is my code:

let result = await axios({
            method: 'post',
            url: 'https://hcaptcha.com/siteverify',
            params: {
                secret: "secret would be here",
                response: req.body.hcap
            }
        });
        let data = result.data || {};
        console.log(result)
        if(!data.success){
            res.send("bad token")
            return
        }
        else{
            res.send("good token") 
        }

I know that the token sent to the server is good.

Here is the error I'm receiving:

'error-codes': [ 'missing-input-response', 'missing-input-secret' ]
Rogue Ram
  • 25
  • 1
  • 5

2 Answers2

0

I ended up finding the solution to be installing the hcaptcha package which made this a lot simpler.

Rogue Ram
  • 25
  • 1
  • 5
0

You have to transfer your data to a URLSearchParams object. The following code works for me:

const res = await axios
    .post(
        "https://hcaptcha.com/siteverify",
        new URLSearchParams({
            secret: process.env.HCAPTCHA_SECRET ?? "",
            response: verificationToken
        })
    )
    .then(res => res.data);