diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..f673a71 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "liveServer.settings.port": 5502 +} \ No newline at end of file diff --git a/index.html b/index.html index 3233671..dec8594 100644 --- a/index.html +++ b/index.html @@ -3,9 +3,18 @@ - Document + Weather App -

Hola Mundo

+
+

Weather App

+

+
+ + + +
+
+ - \ No newline at end of file + diff --git a/weather.JSON b/weather.JSON new file mode 100644 index 0000000..93338fe --- /dev/null +++ b/weather.JSON @@ -0,0 +1,11 @@ + \ No newline at end of file diff --git a/weather.css b/weather.css new file mode 100644 index 0000000..e69de29 diff --git a/weather.js b/weather.js new file mode 100644 index 0000000..59d255c --- /dev/null +++ b/weather.js @@ -0,0 +1,19 @@ +/* step 1 - create response object */ +var zipCode = new XMLHttpRequest(); +var zip = prompt("Enter zipcode to get city & state"); + + +/* step 2 - create call back */ + zipCode.onreadystatechange = function() { + if (zipCode.readyState === 4 && zipCode.status === 200) { + let response = JSON.parse(zipCode.responseText); + console.log(response); + let city = response.places[0]["place name"]; + let state = response.places[0]["state abbreviation"]; + document.getElementById('location').innerHTML = city + ", " + state; + } + } +/* step 3 - create an open request */ + zipCode.open('GET', `http://api.zippopotam.us/US/${zip}`); +/* step 4 - send the request */ + zipCode.send(); \ No newline at end of file