Created
November 28, 2019 06:00
-
-
Save harrisonmalone/0369336863843ca0c0ac458c5d302eb2 to your computer and use it in GitHub Desktop.
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
| <!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <meta http-equiv="X-UA-Compatible" content="ie=edge"> | |
| <title>Document</title> | |
| </head> | |
| <body> | |
| <div id="characters"></div> | |
| <script src="./script.js"></script> | |
| </body> | |
| </html> |
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
| const request = fetch("https://swapi.co/api/people/") | |
| const div = document.querySelector('#characters') | |
| request.then(function(response) { | |
| const getJson = response.json() | |
| getJson.then((json) => { | |
| const characters = json.results | |
| characters.forEach((character) => { | |
| const characterDiv = ` | |
| <div> | |
| <p style="color: blue">${character.name}</p> | |
| <p>${character.height}</p> | |
| <hr> | |
| </div> | |
| ` | |
| div.insertAdjacentHTML("afterbegin", characterDiv) | |
| }); | |
| }) | |
| }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment