From 38e23cf767d6a8df55d21b3acab133f016459829 Mon Sep 17 00:00:00 2001 From: Jason Williams Date: Sun, 25 Aug 2019 15:31:41 -0600 Subject: [PATCH] Video 38 --- weather-app/app.js | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/weather-app/app.js b/weather-app/app.js index 5c52f2b..7b1322e 100644 --- a/weather-app/app.js +++ b/weather-app/app.js @@ -1,12 +1,23 @@ const geocode = require('./utils/geocode') const forecast = require('./utils/forecast') -geocode('Boston', (error, data) => { - console.log('Error', error) - console.log('Data', data) -}) +const address = process.argv[2] -forecast(-75.7088, 44.1545, (error, data) => { - console.log('Error', error) - console.log('Data', data) -}) +if (!address) { + console.log('Please provide an address') +} else { + geocode(address, (error, data) => { + if (error) { + return console.log(error) + } + + forecast(data.latitude, data.longitude, (error, forecastData) => { + if (error) { + return console.log(error) + } + + console.log(data.location) + console.log(forecastData) + }) + }) +}