如何使用 Github API 从存储库中的目录获取文件名

How do I get file names from a directory in a repository using Github API

我正在尝试制作一个电子应用程序来获取存储库中目录的文件名。我只是不知道如何使用 api 执行此操作。我知道有办法,就是不知道怎么办。

例如:

我想使用 api.

获取 github 存储库的 src/ 目录中的文件名

我使用 axios 发出 api 请求。

使用获取存储库内容端点,已记录 here

使用 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));