Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

203
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!