async function fetchRepoData(repo, dir) {
  return new Promise((resolve, reject) => {
    fetch(`http://localhost:${contentApiPort}/${repo}`)
      .then((response) => response.json())
      .then((data) => {
        // Make sure the files are in the correct directory and are not a
        // directory themselves. blob --> binary large object, meaning file
        let files = data.tree.filter((obj) => {
          return obj.path.startsWith(dir) && obj.type == 'blob';
        });
        // Format files so the filename and URL are easily accessible
        files = files.map((file) => {
          let fileName = file.path.slice(dir.length + 1);
          return {
            fileName: fileName,
            url: file.url,
          };
        });
        // Resolve the finished file
        resolve(files);
      })
      .catch((err) => {
        // Log to the console & reject the promise
        console.error(`Error Fetching Repository: ${err}`);
        reject(`Error Fetching Repository: ${err}`);
      });
  });
}
/**
 * Fetches a list of files from the specified repo & subdirectory. This list
 * contains the URL with which to fetch the data of these files.
 * @param {string} repo the GitHub repository to fetch from
 * @param {string} dir (optional) the desired subdirectory in the repository
 * @returns {promise<array>} When the promise successfully resolves, an array of
 *                           objects containing the URL of the raw file data. A
 *                           an error message string if rejected
 */
Fetches a list of files from the specified repo & subdirectory. This list
contains the URL with which to fetch the data of these files.
@param {string} repo the GitHub repository to fetch from
@param {string} dir (optional) the desired subdirectory in the repository
@returns {promise} When the promise successfully resolves, an array of
objects containing the URL of the raw file data. A
an error message string if rejected
Fetches a list of files from the specified repo & subdirectory . This list contains the URL with which to fetch the data of these files . @param { string } repo the GitHub repository to fetch from @param { string } dir ( optional ) the desired subdirectory in the repository @returns { promise } When the promise successfully resolves an array of objects containing the URL of the raw file data . A an error message string if rejected
async function fetchRepoData(repo, dir) {
  return new Promise((resolve, reject) => {
    fetch(`http://localhost:${contentApiPort}/${repo}`)
      .then((response) => response.json())
      .then((data) => {
        let files = data.tree.filter((obj) => {
          return obj.path.startsWith(dir) && obj.type == 'blob';
        });
        files = files.map((file) => {
          let fileName = file.path.slice(dir.length + 1);
          return {
            fileName: fileName,
            url: file.url,
          };
        });
        resolve(files);
      })
      .catch((err) => {
        console.error(`Error Fetching Repository: ${err}`);
        reject(`Error Fetching Repository: ${err}`);
      });
  });
}
async function fetchRepoData ( repo , dir ) { return new Promise ( ( resolve , reject ) => { fetch ( ` ${ contentApiPort } ${ repo } ` ) . then ( ( response ) => response . json ( ) ) . then ( ( data ) => { let files = data . tree . filter ( ( obj ) => { return obj . path . startsWith ( dir ) && obj . type == 'blob' ; } ) ; files = files . map ( ( file ) => { let fileName = file . path . slice ( dir . length + 1 ) ; return { fileName : fileName , url : file . url , } ; } ) ; resolve ( files ) ; } ) . catch ( ( err ) => { console . error ( ` ${ err } ` ) ; reject ( ` ${ err } ` ) ; } ) ; } ) ; }
Fetches a list of files from the specified repo & subdirectory.
Fetches a list of files from the specified repo & subdirectory .
// Make sure the files are in the correct directory and are not a // directory themselves. blob --> binary large object, meaning file // Format files so the filename and URL are easily accessible // Resolve the finished file // Log to the console & reject the promise