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

126
Views
El valor JSON da indefinido

Creé una aplicación de electrones que obtiene un valor JSON de https://complimentr.com/api . Pero, cuando hace clic en el botón para establecer el valor innerHTML en el valor JSON, da el temido 'indefinido'.

 // create a variable called url and set it to the url of the website var url = "https://evilinsult.com/generate_insult.php?lang=en&type=json"; // create a variable called response and set it to the response of the get request request(url, function(error, response, body){ var data = JSON.parse(body); console.log(data.compliment); const btn = document.getElementById('button-1'); btn.onclick = () => { document.body.innerHTML = data.compliment } });

¿Hay alguna razón por la que esto no funciona? Soy nuevo en JavaScript, por lo que esto podría ser una solución fácil.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Debería ser respuesta. cumplido, no datos. cumplido.

console.log(respuesta.cumplido);

about 4 years ago · Juan Pablo Isaza 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!