-
Notifications
You must be signed in to change notification settings - Fork 4
/
index.html
34 lines (31 loc) · 879 Bytes
/
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
<!DOCTYPE html>
<html>
<head>
<title>Display IP Address</title>
</head>
<body>
<h1>Carbon Equivalent for a Taxi</h1>
<h2 id=carbonEquivalent></h2>
<script>
fetch("https://carbonfootprint1.p.rapidapi.com/CarbonFootprintFromPublicTransit?distance=5000&type=Taxi", {
"method": "GET",
"headers": {
"x-rapidapi-host": "carbonfootprint1.p.rapidapi.com",
"x-rapidapi-key": "b96c268c46msh6164d76db47a4fcp1bcf5ejsncad1a0d03078"
}
})
.then(function (response) {
return response.json();
})
.then(function (myJson) {
document.querySelector("#carbonEquivalent").innerHTML = myJson.carbonEquivalent;
var theDATA = JSON.parse('{ "name":"John", "age":30, "city":"New York"}');
console.log(myJson.carbonEquivalent);
console.log(theDATA);
})
.catch(err => {
console.log(err);
});
</script>
</body>
</html>