How to get all the files of a Github repository using Javascript to create an index.html to access all the files

gitblanc

I'm trying to create an easy-access document to all the files of my repository (they are all written in Markdown).

The idea is to make an script in .js that analyzes the repository and lists all the files like links to access to them. (An easy way to see the files from mobile for example)

I've tried to use this code, but it doesn't work to me :/ :

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();
gmad

You are not passing in the url parameter.

The request hast to look like this:

const url = "https://api.github.com/repos/gitblanc/Obsidian-Notes/contents/"

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

You had a typo (all caps) with the url variable.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How to read all text files in Github repository?

GitHub get a list of all files in a repository from raw.githubusercontent?

How to get list files from a github repository folder using R

How to get the absolute path of all files in a Git repository with submodules?

How to enable using Git repository with files with long paths for all users?

wget to get all the files in a directory only returns index.html

Get all the subfolders names and and all the html files in it

How to get list of all files and their raw contents under the GitHub project folder using the Java?

Recursively parse all the .md files from github repository and display the result in html format

how to uncommit all files from remote repository

How to download all repository tree files and folders?

How to remove all installed repository files and folders?

Allow access to pdf files in assets/files subfolder with htaccess angular redirect all to index.html

Create a new link to access all files and folders

How to get header HTML code included in all .html files

Xcode creates GitHub repository but does not push all files

How to redirect all files to index using .htaccess ReWriteEngine?

How to get all files in that folder

How to access all the files when using nested includes in php

How do I view all files of a repository in GitHub on a given commit version?

GitHub: How to show commits for all files in folder

How to create MSdeploy Package using MSBuild for all files in this project folder

How to get all Files Save in Dropbox to my HTML Page

How can I get rid of all script blocks in html files?

How to add external javascript file into all html files in directory?

Access all files on android

How to get all the paths of files inside a specific directory in JavaScript array

How to download all files (but not HTML) from a website using wget?

How to get all files inside a Firebase Storage directory using Flutter