• Empleos
  • Sobre nosotros
  • profesionales
    • Inicio
    • Empleos
    • Cursos y retos
  • empresas
    • Inicio
    • Publicar vacante
    • Nuestro proceso
    • Precios
    • Evaluaciones
    • Nómina
    • Blog
    • Comercial
    • Calculadora de salario

0

259
Vistas
Github user finder api, how to return multiple users per search? JS

Hello I am using github api to create github user finder. my question is how to manipulate on api link to get users which include e.target.value of the searchbar and not only that one that exactly matches.

here is my code

const [finalData, setFinalData] = useState([]);

const handleSearch = async (e) => {
try {
  const URL = `https://api.github.com/users/${e.target.value}? 
  client_id=e25d1dbedde5215999ef&client_secret=ee080580b7c4f19688ccaef6844c3fe88bb811d`;

  Promise.all([fetch(URL).then((res) => res.json())]).then((data) => {
    if (data) {
      setData(data);
    }
  });
  } catch (err) {
  console.log(err);
  }
  };

 const setData = (data) => {
  data && setFinalData(data);
  };
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/16.6.3/umd/react.production.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.6.3/umd/react-dom.production.min.js"></script>

over 3 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

You can use the Search users endpoint. There is a query parameter (q) that allows you to use multiple search criteria documented here

Here's an example using Octokit, but if you still want to use fetch, the endpoint should be https://api.github.com/search/users

Note: I really hope the client secret you are exposing here is for a test application.

Search GitHub users                                                                                 View in Fusebit
const userSearch = ''; // Specify the search text here
const usersResponse = await octokit.rest.search.users({
   q: userSearch,
   per_page:100
});

const { total_count, items } = usersResponse.data;
console.log(`Listing ${items.length} users of ${total_count} \n`, items.map(user => user.login));

over 3 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Nuestro proceso Comercial
Legal
Términos y condiciones Política de privacidad
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recomiéndame algunas ofertas
Necesito ayuda