Morning Challenge

Goal

Master callbacks

callback-hell

Steps

  1. Pair up and choose 1-2 API(s) you have already used. If you feel brave, by all means try new ones, but do mind the timeline.
  2. Perform a series of combined(chained) asynchronous operations with the APIs.

If you don't have an idea, try this:

  1. Start from a physical address(street name and street number) and retrieve location info with Google Maps geocoding
  2. Retrieve the weather forecast for the next 5 days for that location with MetaWeather API. You will probably need 2 separate calls for that (one for location id, one for weather result).
  3. Store the each day's forecast in a separate json file. If you haven't tried node's fs module yet, the docs are here.

Bonus

You can try this at home if you don't have time during the challenge.

  1. Try to use the exec function from node's child-process module to perform bash commands. Read the contents of the files in the directory where you saved the json files.
  2. Write a test to check whether those files have the correct content. If you use fs, do not use the synchronous functions.
  3. Delete the files where the forecast predicts bad weather.

Banned:

  • using synchronous functions or setTimeout
  • functions which are longer than 4 lines.
  • promises... :( :( pity, they're actually fun.

results matching ""

    No results matching ""