Now we'll need to pass in some arguments, including a callback function and inside getWeather variable in weather file. We'll need to use those arguments instead of a static lat/lng pair. And we'll also need to call the callback instead of using console.log. The first thing we'll do before we actually change the weather.js code is change the app.js code. There are three arguments to be added. These are lat, lng and callback.
First up we'll want to pass in the latitude. We'll take the static data, like the latitude part from the URL in weather.js, copy it, and paste it right inside of the arguments list in app.js as first argument. The next one will be the longitude. We'll grab that from the URL, copy it, and paste it inside of app.js as the second argument:
// lat, lng, callback
weather.getWeather(39.9396284, -75.18663959999999);
Then we can go ahead and provide the third one, which will be the callback function. This function will get fired once the weather data comes back from the API. I'll use an arrow function that will get those two arguments we discussed earlier in the previous section: errorMessage and weatherResults:
weather.getWeather(39.9396284, -75.18663959999999, (errorMessage, weatherResults) => {
});
The weatherResults object containing any sort of temperature information we want. In this case it could be the temperature and the actual temperature. Now, we have used weatherResults in place of results, and this is because, we want to differentiate weatherResults from the results variable in geocodeAddress.