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
24 lines (23 loc) · 920 Bytes
/
script.js
File metadata and controls
24 lines (23 loc) · 920 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// TODO: add code here
window.addEventListener("load",function(){
this.fetch("https://handlers.education.launchcode.org/static/astronauts.astronauts").then(function(response){
response.json().then(function(astronauts){
console.log(astronauts)
const id=document.getElementById("container");
for(let i=0;i<astronauts.length;i++){
id.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.join(",")}</li>
</ul>
</div>
<img class="avatar" src="images/mae-jemison.jpg">
</div>`
}
})
})
})