-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
72 lines (58 loc) · 2.64 KB
/
index.html
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>NASA API Project-1</title>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"rel="stylesheet"integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD"crossorigin="anonymous">
<style></style>
<script>
function bodyload() {
fetch("https://api.nasa.gov/mars-photos/api/v1/rovers/curiosity/photos?sol=1000&api_key=DEMO_KEY")
.then(function (response) {
return response.json();
}).then(function (data) {
for (var item of data.photos) {
var tr = document.createElement("tr");
var tdId = document.createElement("td");
var tdPreview = document.createElement("td");
var tdCamera = document.createElement("td");
var tdRover = document.createElement("td");
tdId.innerHTML = item.id;
tdPreview.innerHTML = `<img id="displayImage" src=${item.img_src} alt="MarsImage" width="100px" height="100px">`;
tdCamera.innerHTML = item.camera.full_name;
tdRover.innerHTML = item.rover.name;
tr.appendChild(tdId);
tr.appendChild(tdPreview);
tr.appendChild(tdCamera);
tr.appendChild(tdRover);
document.querySelector("tbody").appendChild(tr);
}
})
}
</script>
</head>
<body class="container-fluid">
<div
class="mainDiv d-flex justify-content-center flex-column align-content-center text-center border-1 border-dark ">
<button class="btn btn-primary m-3" onclick="bodyload()">Get</button>
<h1>Mars Images NASA</h1>
</div>
<div>
<table class="table table-hover">
<thead>
<tr>
<th>Photo Id</th>
<th>Preview</th>
<th>Camera Name</th>
<th>Rover Name</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"integrity="sha384-w76AqPfDkMBDXo30jS1Sgez6pr3x5MlQ1ZAGC+nuZB+EYdgRZgiwxhTBTkF7CXvN"crossorigin="anonymous"></script>
</body>
</html>