我正在尝试创建一个易于访问的文档来访问我的存储库中的所有文件(它们都是用Markdown编写的)。
这样做的目的是在.js中创建一个脚本,分析存储库,并列出所有文件,比如访问它们的链接。(例如,查看移动文件的简单方法)
我试过使用这段代码,但它对我不起作用:/:
const xhr = new XMLHttpRequest();
const url = "https://api.github.com/repos/gitblanc/Obsidian-Notes/contents/"
// 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();发布于 2022-11-20 21:53:51
您不会传入url参数。
请求如下所示:
const url = "https://api.github.com/repos/gitblanc/Obsidian-Notes/contents/"
xhr.open('GET', url, true);您有一个带有url变量的错误(所有大写)。
https://stackoverflow.com/questions/74511923
复制相似问题