2019-10-10 18:13:01 +00:00
|
|
|
console.log('Client side javascript file is loaded!')
|
|
|
|
|
2019-10-10 18:30:22 +00:00
|
|
|
const weatherForm = document.querySelector('form')
|
|
|
|
const search = document.querySelector('input')
|
|
|
|
|
|
|
|
weatherForm.addEventListener('submit', (e) => {
|
|
|
|
e.preventDefault()
|
|
|
|
|
|
|
|
const location = search.value
|
|
|
|
|
|
|
|
fetch('/weather?address=' + location).then((response) => {
|
|
|
|
response.json().then((data) => {
|
|
|
|
if (data.error) {
|
|
|
|
console.log(data.error)
|
|
|
|
} else {
|
|
|
|
console.log(data.location)
|
|
|
|
console.log(data.forecast)
|
|
|
|
}
|
|
|
|
})
|
2019-10-10 18:13:01 +00:00
|
|
|
})
|
|
|
|
})
|