First, we do need to remove the comments of geocodeAddress in the app.js.
Next, we'll go ahead and take the console.log statement in the success case and replace it with a console.log call that will print the formatted address:
geocode.geocodeAddress(argv.address, (errorMessage, results) => {
if (errorMessage) {
console.log(errorMessage);
} else {
console.log(results.address);
}
});
This will print the address to the screen, so we know exactly what address we're getting weather data for.
Now that we have our console.log printing the address, we can take the getWeather call, and move it right below the console.log line:
geocode.geocodeAddress(argv.address, (errorMessage, results) => {
if (errorMessage) {
console.log(errorMessage);
} else {
console.log(results.address);
weather.getWeather(39.9396284, -75.18663959999999,
(errorMessage, weatherResults) => {
if (errorMessage) {
console.log(errorMessage);
} else {
console.log(JSON.stringify(weatherResults, undefined, 2));
}
});
}
});
And with this in place we're now really close to actually chaining the two callbacks together. All that's left to do is take these static coordinates and replace them with the dynamic ones, which will be available in the results object.