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

186
Views
JS - TypeError no capturado: no se pueden leer las propiedades de undefined (leyendo 'valor')

Estoy tratando de recibir una respuesta API (que tiene éxito), pero por alguna razón no se puede llamar a la variable fuera de la función, pero estoy bastante seguro de que es una variable global y no local. ¿Qué estoy haciendo mal? También intenté declarar la variable dentro de la función como parámetro.

 const data = null; const xhr = new XMLHttpRequest(); xhr.withCredentials = true; var object1; xhr.addEventListener("readystatechange", function () { if (this.readyState === this.DONE) { object1 = JSON.parse(this.responseText); } }); document.getElementById('thejoke').innerHTML = object1.value; xhr.open("GET", "https://api.chucknorris.io/jokes/random?category=explicit"); xhr.send(data);
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!