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

205
Visualizações
Fetch API visitor counter

First time poster, long time lurker. I am trying to complete part of the Cloud Resume Challenge, where after creating an AWS API gateway that links a Lambda function, I need to write some Javascript to call the API and return the current visitor count from Lambda function.

I have searched a number of solutions but they dont seem to work for me, I feel I am close.

Here is what I have for the script

          <article>
            <script>
              fetch('https://5cabfxax81.execute-api.ap-southeast-2.amazonaws.com/Prod/')
                  .then((response => response.json()))  
                  .then(data => 
                    console.log(data))
                  .then(response=> {document.getElementById("counter").innerHTML = data.count});                                
            </script>
            <p class="subDetails">You are visitor number <span id="counter">loading...</span></p> 
            <p></p>
          </article>

And this is the error I get Error message

Can anyone push me in the right direction? Am I being super stupid here?

about 4 years ago · Santiago Gelvez
2 Respostas
Responde à pergunta

0

I got it!

            <script>
              fetch('https://5cabfxax81.execute-api.ap-southeast-2.amazonaws.com/Prod/')
                  .then((response => response.json()))  
                  .then((data) => {document.getElementById("counter").innerHTML = data})                                
            </script>
            <p class="subDetails">You are visitor number <span id="counter">loading...</span></p> 
            <p></p>
          </article>
about 4 years ago · Santiago Gelvez Relatório

0

fetch(url, {method:'get'})

You can use that so you don't have to deal with empty data or response

about 4 years ago · Santiago Gelvez Relatório
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