-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
27 lines (18 loc) · 790 Bytes
/
app.js
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
let button = document.querySelector('.button')
let inputvalue = document.querySelector('.inputValue')
let nameVal = document.querySelector('.name');
let temp = document.querySelector('.temp');
let desc = document.querySelector('.desc');
button.addEventListener('click', function(){
// Fection data from open weather API
fetch(`https://api.openweathermap.org/data/2.5/weather?q=${inputvalue.value}&units=metric&appid=108dd9a67c96f23039937fe6f3c91963`)
.then(response => response.json())
.then(
displayData)
.catch(err => alert('Wrong City name'));
})
// Function to diplay weather on html document
const displayData=(weather)=>{
temp.innerText=`${weather.main.temp}°C`
desc.innerText=`${weather.weather[0].main}`
}