Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

316
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda