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

154
Views
Consulte y obtenga datos de un punto final a través de una entrada de barra de búsqueda en javascript

Este punto final http://vk-data:8003/v1/entity/ devuelve esto:

 [ { "id": "country", "url": "http://vk-data:8003/v1/entity/country", "name": "Countries", "description": "All the countries in the world" }, { "id": "data-site", "url": "http://vl-data:8003/v1/entity/data-site", "name": "World data storage", "description": "A catalog of health data" } ]

Quiero escribir una función que permita al usuario acceder a los data-site o del country a través de una entrada en la barra de búsqueda.

¿Cómo puedo obtener mi código para hacer eso? Esto es lo que tengo hasta ahora.

 <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"> <link rel="stylesheet" href="css/styles.css"> </head> <body> <button id="catalog" onclick="RetrieveCatalog()">Get Catalog</button> <input type="text" placeholder="Search for User" onChange={(e) => RetrieveEntities(e.target.value)} className="input_search" /> <button onClick={fetchData} className="search_button">Search Github</button> <script> //fetch catalog function function RetrieveCatalog(){ //http request fetch("http://vk-data:8003/v1/entity/") .then(function(data){ console.log(data) return data.json() }) .then(function(data){}) .catch(error => console.error(error)) } //fetch catalog function function RetrieveEntities(){ //http request fetch("http://vk-data:8003/v1/entity/${entities}") .then(function(data){ console.log(data) return data.json() }) .then(function(data){}) .catch(error => console.error(error)) } </script> </body> </html>
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Creo que el problema es que te has confundido entre la sintaxis JSX y HTML.


Hay algunas áreas en las que te has confundido entre los dos. Aquí están los lugares para arreglar.

  1. En la etiqueta <input> , cambie el atributo onChange a onchange . Además, rodee la función con comillas ( "" ) en lugar de llaves ( {} ).

     <input onchange="(e) => RetrieveEntities(e.target.value)" />
  2. En la misma etiqueta <input> , cambie el atributo className a class .

     <input class="input_search" />
  3. En el elemento <button> , cambie el atributo onClick a onclick , además de rodear el valor con comillas.

     <button onclick="fetch"></button>
  4. En la etiqueta <button> , cambie className a class .

     <button class="search_button"></button>

Estos cambios en su código HTML deberían ayudar a resolver el problema.

about 4 years ago · Juan Pablo Isaza 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!