Skip to content

Commit b21f2c9

Browse files
committed
fetchstudio
1 parent 53e28ce commit b21f2c9

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

fetch/studio/script.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,27 @@
11
//TODO: Add Your Code Below
2+
window.addEventListener("load", function(){
3+
// TODO: fetch planets JSON
4+
fetch("https://handlers.education.launchcode.org/static/astronauts.json").then(function(response) {
5+
response.json().then(function(json) {
6+
const container = document.getElementById("container");
7+
let astronauts = '';
8+
for(let i=0;i<json.length;i++){
9+
astronauts +=`
10+
11+
<div class="astronaut">
12+
<div class="bio">
13+
<h3>${json[i].firstName} ${json[i].lastName}</h3>
14+
<ul>
15+
<li>Hours in space: ${json[i].hoursInSpace}</li>
16+
<li style="color:green">Active: ${json[i].active}</li>
17+
<li>Skills: ${json[i].skills}</li>
18+
</ul>
19+
</div>
20+
<img class="avatar" src="${json[i].picture}">
21+
</div>`
22+
}
23+
container.innerHTML = astronauts;
24+
});
25+
});
26+
});
27+

0 commit comments

Comments
 (0)