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
27 lines (24 loc) · 1 KB
/
script.js
File metadata and controls
27 lines (24 loc) · 1 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
// TODO: add code here
window.addEventListener("load", function() {
let result = document.getElementById("container");
fetch("https://handlers.education.launchcode.org/static/astronauts.json").then(function(response) {
response.json().then(function(data) {
console.log(data);
for (let i=0; i < data.length; i++) {
result.innerHTML += `
<div class="astronaut">
<div class="bio">
<h3>${data[i].firstName} ${data[i].lastName}</h3>
<ul>
<li>Hours in space: ${data[i].hoursInSpace}</li>
<li>Active: ${data[i].active}</li>
<li>Skills: ${data[i].skills}</li>
</ul>
</div>
<img class="avatar" src="${data[i].picture}">
</div>
`;
}
});
});
});