{"size": 635, "ext": "js", "max_stars_repo_path": "Week2/lecture-exercises.js", "max_stars_repo_name": "nuanprae/JavaScript2", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Week2/lecture-exercises.js", "max_issues_repo_name": "nuanprae/JavaScript2", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Week2/lecture-exercises.js", "max_forks_repo_name": "nuanprae/JavaScript2", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 35.2777777778, "max_line_length": 101, "alphanum_fraction": 0.7496062992}
async function getRandomAdvice() {
  const adviceReq = fetch('https://api.adviceslip.com/advice'); // send request
  const adviceResponse = await adviceReq; // wait until something comes back
  // const jsonString = await adviceResponse.text();
  // return jsonString
  // const adviceData = JSON.parse(jsonString)
  // return jsonString
  const adviceData = await adviceResponse.json(); // parses JSON string into native JavaScript object
  return adviceData.slip.advice;
}

async function setRandomAdvice() {
  const adviceEl = document.getElementById('advice');
  adviceEl.innerText = await getRandomAdvice();
}

setRandomAdvice();
