Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

335
Views
How can i target a search bars input value and store it into a variable to use in an api fetch in javascript for flickr

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)
about 4 years ago · Santiago Gelvez
1 answers
Answer question

0

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 */
})
about 4 years ago · Santiago Gelvez Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!