Exercise Monday

Goal: Practice making API calls in JavaScript. Start by following along with the pre-work and then build out a basic application that uses an API call. Each project should include a full development environment, a .env file for sensitive API variables, and complete README instructions, including instructions for setting up an API key as needed. Make sure to practice parsing JSON, too.

Warm Up


  • What is a promise? What are the advantages and disadvantages of using a promise for async code?
  • What is a static method? How is a static method different from an instance method?
  • How can we use callbacks to handle async code?
  • What causes callback hell and how can we avoid it?

Code


OpenWeather API

Follow along with the lessons to update the weather API project to use separate business logic and static methods.

Project Refactor

Next, refactor one of the projects you worked on in your last class to use promises. Once again, make sure that business logic is properly separated. Make sure to use static methods, too.

Dino Ipsum API

Use this API to allow your users to generate dinosaur themed Lorem Ipsum. Use it any way you like - for instance, you could create a dinosaur themed game along the lines of hangman. Note: Be sure you set your output format to JSON, not HTML or text.

Peer Code Review


  • Does the application have a fully functioning development environment?
  • Does the application successfully wrap an API call in a promise?
  • Are business and user interface logic separated?
  • Are API keys stored in a .env file and protected?
  • Does the README include instructions for setting up the project including getting an API key and adding it to a .env file?

Lesson 20 of 26
Last updated October 12, 2021