async function fetchFiles(files) {
  return new Promise((resolve, reject) => {
    const downloaded = []; // Where the downloaded files will be stored
    files.forEach((file) => {
      fetch(file.url)
        .then((response) => response.json())
        .then((data) => {
          // Push the newly downloaded content into the array
          downloaded.push({
            name: file.fileName,
            type: 'string',
            // The buffer converts the content from base64 encoding
            data: Buffer.from(data.content, 'base64').toString('utf-8'),
          });
          // Resolve if that was the final file to be added to the array
          if (downloaded.length == files.length) resolve(downloaded);
        })
        .catch((err) => {
          // Log to the console & reject the promise
          console.error(`Error while fetching a file: ${err}`);
          reject(`Error while fetching a file: ${err}`);
        });
    });
  });
}
/**
 * Fetches all of the file data from the supplied files (that were fetched from
 * the repo using fetchRepoData())
 * @param {array<object>} files the desired files to fetch. the output of
 *                              fetchRepoData() formats this parameter for you
 * @returns {array<object>} the base64-decoded data of the given files
 */
Fetches all of the file data from the supplied files (that were fetched from
the repo using fetchRepoData())
@param {array} files the desired files to fetch. the output of
fetchRepoData() formats this parameter for you
@returns {array} the base64-decoded data of the given files
Fetches all of the file data from the supplied files ( that were fetched from the repo using fetchRepoData () ) @param { array } files the desired files to fetch . the output of fetchRepoData () formats this parameter for you @returns { array } the base64 - decoded data of the given files
async function fetchFiles(files) {
  return new Promise((resolve, reject) => {
    const downloaded = []; 
    files.forEach((file) => {
      fetch(file.url)
        .then((response) => response.json())
        .then((data) => {
          downloaded.push({
            name: file.fileName,
            type: 'string',
            data: Buffer.from(data.content, 'base64').toString('utf-8'),
          });
          if (downloaded.length == files.length) resolve(downloaded);
        })
        .catch((err) => {
          console.error(`Error while fetching a file: ${err}`);
          reject(`Error while fetching a file: ${err}`);
        });
    });
  });
}
async function fetchFiles ( files ) { return new Promise ( ( resolve , reject ) => { const downloaded = [ ] ; files . forEach ( ( file ) => { fetch ( file . url ) . then ( ( response ) => response . json ( ) ) . then ( ( data ) => { downloaded . push ( { name : file . fileName , type : 'string' , data : Buffer . from ( data . content , 'base64' ) . toString ( 'utf-8' ) , } ) ; if ( downloaded . length == files . length ) resolve ( downloaded ) ; } ) . catch ( ( err ) => { console . error ( ` ${ err } ` ) ; reject ( ` ${ err } ` ) ; } ) ; } ) ; } ) ; }
Fetches all of the file data from the supplied files (that were fetched from
 the repo using fetchRepoData())
 @param {array<object>} files the desired files to fetch.
Fetches all of the file data from the supplied files ( that were fetched from the repo using fetchRepoData () ) @param { array<object > } files the desired files to fetch .
// Where the downloaded files will be stored // Push the newly downloaded content into the array // The buffer converts the content from base64 encoding // Resolve if that was the final file to be added to the array // Log to the console & reject the promise