trying to make a geolocator with a picture search feature associated with the geo location for the user and display on the DOM. want to target the search bars input, store it into a variable, use the variable in my fetch request from a flickr.com API. so the user would type in the search bar, and click the search button and the input from which they type is in the fetch request. declared the variable VALUE. tried to change the variable from the keydown. but wont work in the fetch request. comes up blank and I get an HTTP error.
const searchBar = document.querySelector('#search-Bar')
let value
searchBar.addEventListener('keydown', (e) => {
value = e.target.value
console.log(value)
})
fetch("https://shrouded-mountain-15003.herokuapp.com/https://flickr.com/services/rest/?api_key=00a31f12afffd2cff1ceeefd8cb8f3bb&format=json&nojsoncallback=1&method=flickr.photos.search&safe_search=1&per_page=5&lat="
+latitude+"&lon="+longitude+"&text="+value)
const searchBar = document.querySelector(“input#search-bar”)
const value = searchBar.value
or if you want to get the value every time an input value changes
searchBar.addEventListener(“change”, (e) => {
const value = e.target.value
/* Whatever you want to do with the value */
})