Morning Challenge
Goal
Master callbacks
Steps
- 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.
- Perform a series of combined(chained) asynchronous operations with the APIs.
If you don't have an idea, try this:
- Start from a physical address(street name and street number) and retrieve location info with Google Maps geocoding
- 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).
- 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.
- 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. - Write a test to check whether those files have the correct content. If you use fs, do not use the synchronous functions.
- 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.