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

319
Views
Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'length')

I need to get my details using API on Webex, but i when i click on the button that suppose to get an output of my details, instead i get this error.

edit: I tried to add console.log(data) as commenter huy suggested, but it only displays my details on the console, and it still has the error length data.items undefined. How do I define the data.items? Anyway, thank you commenters for answering my question.

    document.getElementById('getDetail').addEventListener('click', getDetail);

    function getDetail(){
        fetch('https://webexapis.com/v1/people/me', {
            method: 'GET',
            headers: {
                'Content-type': 'application/json',
                'Authorization': `Bearer ${token}`
            },
        })
        .then(function(res){
            return res.json();
        })
        .then(function(data){
            let output ='';
            for(let i=0;i<data.items.length;i++){
                output+=`
                     <ul>
                        <li>${data.items[i].id}</li>
                        <li>${data.items[i].displayName}</li>
                        <li>${data.items[i].nickName}</li>
                        <li>${data.items[i].firstName}</li>
                        <li>${data.items[i].lastName}</li>
                        <li>${data.items[i].emails}</li>
                    </ul>
                `;
            }
            document.getElementById('getDetail').innerHTML = output;
        })
    }
</script>
about 4 years ago · Juan Pablo Isaza
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!