Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

456
Visualizações
How to verify ReCAPTCHA token in js?

I have written the following function in js to verify a ReCAPTCHA token:

export async function validateHuman(token) {
  const secret = "funny_little_secret";
  const response = await fetch(
    "https://www.google.com/recaptcha/api/siteverify?secret=" +
      secret +
      "&response=" +
      token,
    { method: "POST" }
  );

  const data = response.json();

  return data.success;
}

For reasons I do not understand, I get a fetch error while running this. I have looked in to a few other versions of the functions but have not yet found a solution.

Moreover, the token is correct and is produced according to the documentation, so I am wondering whether there is something wrong about my secret, as I have seen others use something along the lines of process.env.secret, which I have tried without success, or it there is something I do not understand about the fetch function.

This is the complete error:

Uncaught TypeError: Failed to fetch
validateHuman @ http://localhost:3000/static/js/bundle.js:3384:26

thanks in advance

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda