-
-
Save Ifmr24/0df44a2a7dd1ac7248836e53d5c0511c to your computer and use it in GitHub Desktop.
JS Leer API JSON 2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| document.querySelector('#boton').addEventListener('click', function(){ | |
| traer() | |
| }); | |
| function traer(){ | |
| fetch('https://randomuser.me/api') | |
| .then( res => res.json()) | |
| .then( data => { | |
| console.log(data.results['0']) | |
| contenido.innerHTML = ` | |
| <img src="${data.results['0'].picture.large}" width="200px" class="img-fluid rounded-circle"> | |
| <br><br> | |
| <b>Name: </b> ${data.results['0'].name.title} ${data.results['0'].name.first} ${data.results['0'].name.last}<br> | |
| <b>Gender: </b> ${data.results['0'].gender}<br> | |
| ` | |
| }) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment