我正在try 制作一款Electron 应用程序,它可以获取存储库中某个目录的文件名.我只是不知道如何使用API来做到这一点.我知道有一种方法,但我不知道怎么做.
For example:
我想使用api获取github存储库的src/目录中的文件名.
我使用axios来发出API请求.
我正在try 制作一款Electron 应用程序,它可以获取存储库中某个目录的文件名.我只是不知道如何使用API来做到这一点.我知道有一种方法,但我不知道怎么做.
For example:
我想使用api获取github存储库的src/目录中的文件名.
我使用axios来发出API请求.
使用Get repository content endpoint,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));