首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何使用Javascript来创建一个index.html来访问所有文件,以获取Github存储库的所有文件

如何使用Javascript来创建一个index.html来访问所有文件,以获取Github存储库的所有文件
EN

Stack Overflow用户
提问于 2022-11-20 20:55:01
回答 1查看 27关注 0票数 -2

我正在尝试创建一个易于访问的文档来访问我的存储库中的所有文件(它们都是用Markdown编写的)。

这样做的目的是在.js中创建一个脚本,分析存储库,并列出所有文件,比如访问它们的链接。(例如,查看移动文件的简单方法)

我试过使用这段代码,但它对我不起作用:/:

代码语言:javascript
复制
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();
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-11-20 21:53:51

您不会传入url参数。

请求如下所示:

代码语言:javascript
复制
const url = "https://api.github.com/repos/gitblanc/Obsidian-Notes/contents/"

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

您有一个带有url变量的错误(所有大写)。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/74511923

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档