Summary
In this chapter, we learned about how to set up yargs for the weather-app
file and how to include user input in it. Next, we looked into how to handle errors inside of our callback functions and how to recover from those errors. We simply added else
/if
statements inside of the callback
function. Callbacks are just one function, so in order to figure out if things went well or if things didn't go well, we have to use else
/if
statements, this lets us do different things, such as print different messages, depending on whether or not we perceive the request to have gone well. Then, we made our first request to the weather API, and we looked into a way to fetch the weather based off of the latitude-longitude combination.
Last, we looked in chaining the geocodeAddress
and getWeather
call functions. We took that request call that was originally in app.js
, and we moved it into weather.js
, defining it there. We used a callback to pass the data from weather.js
into app.js
where we imported...