6

I'm trying to make an electron app that gets the file names of a directory in a repository. I just don't know how to do this with the api. I know there is a way, I just don't know how.

For example:

I want to get the file names in the src/ directory of a github repository using the api.

I use axios to make api requests.

1 Answer 1

4

Use Get repository content endpoint, documented here

Check out an example using Octokit

List Repository contents                                                                                 View in Fusebit
// If you don't send the path property, by default will send the contents from the root level
const repoContent = await github.rest.repos.getContent({
  owner: 'repo-owner',
  repo: 'repo-name'
});
  
console.log('Files found at root level', repoContent.data.map((file) => file.name));

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.