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

320
Visualizações
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
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