jQuery Parsing JSON and Git Raw -> Undefined Object

Working on the quote generator here with the remotely stored JSON quotes here.

My function to pull the data is:

function getQuotes(){
return $.getJSON('https://raw.githubusercontent.com/themagicbean/bojackquotejson/master/bojackquotes')
.done(function(retrievedData) {
  console.log(retrievedData);
  let quotesData = retrievedData;
  console.log('got data');
  let quotes = retrievedData.quotes;
  console.log(quotes);
  console.log("extracted the array of quotes");
  //from here not working
  let parsedQuotes = JSON.parse(quotes);
  console.log(quotesData);
  console.log("extracted the quote objects from the array")
}).fail(function(error) {
  // Something wrong happened.  Like GOT Season 8.
  console.error('We could not fetch or parse the data:', error);
});
}

I get the object, and the array of quotes. The console logs “extracted the array of quotes” but stops there.

If I remove the array extraction step, so the code is like so:

function getQuotes(){
return $.getJSON('https://raw.githubusercontent.com/themagicbean/bojackquotejson/master/bojackquotes')
.done(function(retrievedData) {
  console.log(retrievedData);
  let quotesData = retrievedData;
  console.log('got data');
  /*
  let quotes = retrievedData.quotes;
  console.log(quotes);
  console.log("extracted the array of quotes");
  //from here not working
  */
  let parsedQuotes = JSON.parse(retrievedData);
  console.log(quotesData);
  console.log("extracted the quote objects from the array")
}).fail(function(error) {
  // Something wrong happened.  Like GOT Season 8.
  console.error('We could not fetch or parse the data:', error);
});
}

Then it similarly gets the data, but does not parse.

How do I parse the object? Thanks!

quotes is an array of objects, $.getJSON has parsed it already, $.get will do the same (unless it doesn’t guess the dataType correctly, I’m guessing).

JSON.parse()

The JSON.parse() method parses a JSON string, constructing the JavaScript value or object described by the string.

quotes.forEach(quote => console.log(quote.author, quote.quote))