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

117
Views
Making dynamic search bar for fetched data from API url

I have an API URL written by json contain data for some characters and I converted into Html by this javascript

async function getsrch() {
    
    
    let url = "https://www.urlcontent.com/api/characters?name=charactername";
alert(url);
    try {
        let res = await fetch(url);
        return await res.json();
    } catch (error) {
        console.log(error);
    }
  }
  async function rendersrch() {
    let users = await get4srch();
    let html = '';
    users.forEach(user => {
      let htmlSegment = `


      <div class="col-3 mt-3">
        <div class="card mx-3" style="  border-color: #114C38;">
          <img src="${user.img}" class="card-img img-thumbnail" alt="..." >
        <div class="card-body">
          <h5 class="card-title">${user.name}</h5>
          <a href="CharDetails.html?id=${user.char_id}" class="btn btn-primary float-end">More</a>
        </div>
      </div>
      </div>

                            `;

        html += htmlSegment;
    });

    let container = document.querySelector('.search');
// i made div with class called (search)
    container.innerHTML = html;
}

renderchar();

and it works well

this url contains details for 62 characters , and I want to make a search bar that shows the name I wrote in the search bar I made a form in the html by this way

  <label for="domTextElement">Name: </label>
 <input type="text" id="domTextElement" >

 <button type="button" onclick="getsrch()" value="value">
     click me!!
 </button>

and I added this for the script

  let str = document.getElementById("domTextElement").value

then I changed the URL into

let url = "https://www.urlcontent.com/api/characters?name="+str;

But when I type in the search there are not any reponse Where is the problem?

about 4 years ago · Santiago Trujillo
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!