From 4146e16fd1d78d3e874ac1e2487f124883f5d68f Mon Sep 17 00:00:00 2001 From: DonaldMitchel <90492006+DonaldMitchel@users.noreply.github.com> Date: Tue, 11 Apr 2023 12:58:31 -0400 Subject: [PATCH] Add files via upload --- script.js | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 script.js diff --git a/script.js b/script.js new file mode 100644 index 0000000..7ee6d9a --- /dev/null +++ b/script.js @@ -0,0 +1,30 @@ + +const apiKey = '19ae3f4e8e7548f3bb3220314230504' +const button = document.querySelector('#submitButton') + +button.addEventListener('click', async () => { + +const input = document.querySelector('#textInput').value +let city = document.querySelector('h1') +let temp = document.querySelector('h2') +let humid = document.querySelector('h3') + + +let response = await axios.get(`http://api.weatherapi.com/v1/current.json?key=${apiKey}&q=${input}&aqi=no`) +let cityName = response.data.location.name +let cityRegion = response.data.location.region +let cityTemp = response.data.current.temp_f +let cityCondition = response.data.current.condition.text +let cityConditionIcon = response.data.current.condition.icon +let humidity = response.data.current.humidity +let wind = response.data.current.gust_mph + + +console.log(cityName); +console.log(response); + +city.innerHTML = `${cityName}, ${cityRegion}` +temp.innerHTML = `It is currently ${cityTemp} degrees fahrenheit and the weather conditions consist of ${cityCondition} ` +humid.innerHTML = `There is ${humidity}% humidity and we will have wind gusts up to ${wind}MPH` + +}); \ No newline at end of file