diff --git a/index.html b/index.html new file mode 100644 index 0000000..98865f7 --- /dev/null +++ b/index.html @@ -0,0 +1,14 @@ + + + + + + Document + + + +
+
+
+ + \ No newline at end of file diff --git a/main.js b/main.js new file mode 100644 index 0000000..a42f654 --- /dev/null +++ b/main.js @@ -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}' + }) + }) +} \ No newline at end of file diff --git a/style.css b/style.css new file mode 100644 index 0000000..d731d06 --- /dev/null +++ b/style.css @@ -0,0 +1,3 @@ +*{ + box-sizing: border-box; +}