Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<button>click for location</button>
<div id="center"></div>
<div id="city"></div>
<div id="temp"></div>
</body>
</html>
22 changes: 22 additions & 0 deletions main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
document.querySelector('button').addEventListener('click',letsGo)

function letsGo(){
fetch("https://data.nasa.gov/resource/gvk9-iz74.json")
.then(res => res.json())
.then(data => {
const dataInformed = Math.floor(Math.random() * data.length)
facility = data[dataInformed]
document.querySelector('#center').innerHTML = facility.center
document.querySelector('#city').innerHTML = facility.city +','+ facility.state
let lat = facility.location.latitude
let lon = facility.location.longitude
fetch('https://api.openweathermap.org/data/2.5/weather?lat=${lat}&lon=${lon}&units=imperial&appid=')
.then(res => res.json())
.then(dataTwo =>{
console.log(dataTwo)
let temp = dataTwo.main.temp
let tempRound = Math.trunc(temp)
document.querySelector('#temp').innerHTML = '${tempRound}'
})
})
}
3 changes: 3 additions & 0 deletions style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*{
box-sizing: border-box;
}