Step 9

Let's fetch the data about "schools" and "terms" from SIS API.

Update script.js to include the following:

const key = "USE_YOUR_KEY"; // trrible practice!
// should never save API key directly in source code
// in particular when it can potentily be seen by users

const requestOptions = {
  method: "GET",
  redirect: "follow",
};

fetch(
  `https://sis.jhu.edu/api/classes/codes/schools?key=${key}`,
  requestOptions
)
  .then((response) => response.json())
  .then((data) => populateSelector("schools", data))
  .catch((error) => console.log("error", error));

fetch(`https://sis.jhu.edu/api/classes/codes/terms?key=${key}`, requestOptions)
  .then((response) => response.json())
  .then((data) => populateSelector("terms", data))
  .catch((error) => console.log("error", error));

Make note of the use of then clauses.