diff --git a/assets/js/api.js b/assets/js/api.js index ede68e1..56406cf 100644 --- a/assets/js/api.js +++ b/assets/js/api.js @@ -6,7 +6,7 @@ const api_key = "8c2afaacf65df1976579f048d2fc4e25"; @param {function} callback callback */ export const fetchData = function (URl, callback) { - fetch(`${URL}&appid=${api_key}`) + fetch(`${URl}&appid=${api_key}`) .then((res) => res.json()) .then((data) => callback(data)); }; diff --git a/assets/js/app.js b/assets/js/app.js index 45523fd..a8dd56d 100644 --- a/assets/js/app.js +++ b/assets/js/app.js @@ -10,6 +10,7 @@ const searchView = document.querySelector("[data-search-view]"); const searchTogglers = document.querySelectorAll("[data-search-toggler]"); const toggleSearch = () => searchView.classList.toggle("active"); addEventOnElements(searchTogglers, "click", toggleSearch); +// ---searching--- const searchFeild = document.querySelector("[data-search-field]"); const searchResult = document.querySelector("[data-search-result]"); let searchTimeOut = null; @@ -24,23 +25,24 @@ searchFeild.addEventListener("input", function () { } else { searchFeild.classList.add("searching"); } - if (searchFeild.Value) { + if (searchFeild.value) { searchTimeOut = setTimeout(() => { fetchData(url.geo(searchFeild.value), function (location) { // console.log(searchFeild.value); searchFeild.classList.remove("searching"); searchResult.classList.add("active"); searchResult.innerHTML = `
`; +London
+State of London, GB
+