forked from LaunchCodeEducation/Fetch-and-JSON-Studio
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
28 lines (25 loc) · 1.16 KB
/
script.js
File metadata and controls
28 lines (25 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// TODO: add code here
window.addEventListener("load",function() {
this.fetch("https://handlers.education.launchcode.org/static/astronauts.json").then( function(response) {
response.json().then( function(astronauts){
console.log(astronauts);
console.log(astronauts.length);
const div = document.getElementById("container");
for(let i = 0; i < astronauts.length; i++) {
console.log(astronauts[i])
div.innerHTML += `
<div class="astronaut">
<div class="bio">
<h3>${astronauts[i].firstName} ${astronauts[i].lastName}</h3>
<ul>
<li>Hours in space: ${astronauts[i].hoursInSpace}</li>
<li>Active: ${astronauts[i].active}</li>
<li>Skills: ${astronauts[i].skills}</li>
</ul>
</div>
<img class="avatar" src="${astronauts[i].picture}">
</div>`
}
})
})
})