forked from LaunchCodeEducation/Fetch-and-JSON-Studio
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
first astronaut added, still needs additional astronauts
- Loading branch information
Showing
1 changed file
with
31 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,36 @@ | ||
// TODO: add code here | ||
window.addEventListener("load", function () { | ||
this.fetch("https://handlers.education.launchcode.org/static/astronauts.json").then(function (response) { | ||
fetch("https://handlers.education.launchcode.org/static/astronauts.json").then(function (response) { | ||
return response.json(); | ||
|
||
}) | ||
.then() | ||
}) | ||
.then(function (astronauts){ | ||
let container = document.getElementById("container"); | ||
container.innerHTML+= ` | ||
<div class="astronaut"> | ||
<div class="bio"> | ||
<h3>${astronauts[0].firstName} ${astronauts[0].lastName}</h3> | ||
<ul> | ||
<li>Hours in space: ${astronauts[0].hoursInSpace}</li> | ||
<li>Active: ${astronauts[0].active}</li> | ||
<li>Skills: ${astronauts[0].skills}</li> | ||
</ul> | ||
</div> | ||
<img class="avatar" src="${astronauts[0].picture}"> | ||
</div> | ||
` | ||
|
||
}) | ||
}) | ||
|
||
// <div class="astronaut"> | ||
/* <div class="bio"> | ||
<h3>Mae Jemison</h3> | ||
<ul> | ||
<li>Hours in space: 190</li> | ||
<li>Active: false</li> | ||
<li>Skills: Physician, Chemical Engineer</li> | ||
</ul> | ||
</div> | ||
<img class="avatar" src="images/mae-jemison.jpg"> | ||
</div> */ |