Stackoverflow API connection example

Exercise : Get object data and dynamically create web page elements with code

  1. Select the page elements, and create a variable for the URL path to connect to.
  2. Using the btn onclick event, connect to the API with fetch.
  3. Once data is retrieved, output the array of items into the web page.  Create a separate function to handle the element creation and adding to the page.
  4. Loop through all the items in the data, using document.createElement() create page elements, append them to the element with the class of output.

Leave a Comment