Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

235
Vistas
How to create an array with files from a Github repository with js?

I'm making a website with HTML, and I want to create a table with midi files that I've put in a Github repository. For this I just imagined myself inserting all of these files into an array, and then generating the table based on the files in the array. Storing the names of the files in an array and then just finding the file based on the names would probably also work.

But the issue is that I have no idea how to get all files (or their names) located in a folder (which is in a Github repository). This feels like a pretty simple thing to do, but I've searched for a while and found nothing that helped.

So, does anybody know how I could create an array with files from a Github repository with js?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

After looking through GitHubs API I found a thing that lets me get the contents of a repository!

    const xhr = new XMLHttpRequest();
    const url = "https://api.github.com/repos/-username-/-repo-/contents/:path"
    // Replace -username- with your GitHub username, -repo- with the repository name, and then :path with a path to the file or folder you want to get the content of (leave blank to ge all files of the repository)

    xhr.open('GET', URL, true);

    xhr.onload = function() {
        const data = JSON.parse(this.response);

        console.log(data);
    };
    
    xhr.send();

The API call returns a JSON string with the content of the repository, which is perfect for my case.

Here is a link to the API documentation: https://docs.github.com/en/rest/reference/repos#get-repository-content

Here is a website which helped me understand GitHub API: https://codesnippet.io/github-api-tutorial/

And I want to thank @user2190492 for suggesting to use the GitHub API.

about 4 years ago · Juan Pablo Isaza 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 Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda