The first argument will be results.latitude, which we defined in app.js on the object. And the second one will be results.longitude:
geocode.geocodeAddress(argv.address, (errorMessage, results) => {
if (errorMessage) {
console.log(errorMessage);
} else {
console.log(results.address);
weather.getWeather(results.latitude, results.longitude,
(errorMessage, weatherResults) => {
if (errorMessage) {
console.log(errorMessage);
} else {
console.log(JSON.stringify(weatherResults, undefined, 2));
}
});
}
});
This is all we need to do to take the data from geocodeAddress and pass it in to getWeather. This will create an application that prints our dynamic weather, the weather for the address in the Terminal.
Now before we go ahead and run this, we'll replace the object call with a more formatted one. We'll take both of the pieces of information-the temperature variable and the apparentTemperature variable from weather.js file, and use them in that string in app.js. This means that we can remove the console.log in the else block of getWeather call, replacing it with a different console.log statement:
if (errorMessage) {
console.log(errorMessage);
} else {
console.log();
}
We'll use template strings, since we plan to inject a few variables in; these're currently, followed by the temperature. We'll inject that using weatherResults.temperature. And then we can go ahead and put a period, and add something along the lines of: It feels like, followed by the apparentTemperature property, which I'll inject using weatherResults.apparentTemperature. I'll put a period after that:
if (errorMessage) {
console.log(errorMessage);
} else {
console.log(`It's currently ${weatherResults.temperature}. It feels like
${weatherResults.apparentTemperature}`);
}
We now have a console.log statement that prints the weather to the screen. We also have one that prints the address to the screen, and we have error handlers for both geocodeAddress and getWeather.