trying to use information from an API call to then send a second call.
Here's what I've got:
This is the first API call, I've got it working and rendering; it gathers information for disc golf courses.
async function dgcrGetReq(res, cityName) {
var courseData = {
title: "courses",
courses: null
};
await axios.get(`${dgcrUrl}?key=${dgcrKey}&mode=findloc&city=${cityName}&state=ON&country=CA&sig=${torontoSig}`)
.then(function (response){
//Run the weather API call
courseData.courses = response.data;
res.render("courses", courseData);
}).catch(function (error){
console.log(error);
});
}
Here's the second API call: It collects weather data using latitude and longitude
async function getWeather(res) {
var weatherData = {
title: "Weather Information",
weather: null
};
await axios.get(`${weatherUrl}${weatherKey}`)
.then(function (response){
weatherData.weather = response.data;
res.render("weather", weatherData);
}).catch(function (error){
console.log(error);
});
}
What I need is to collect the latitude and longitude elements from the disc golf API and use them as parameters for the Weather app. I know I need to squeeze the second call into the first somehow but I'm unsure of where it actually belongs. I'm using node.js and axios, looking for solutions that don't stray from those technologies.
Links: DGCR API documentation Open Weather Map Documentation
Thanks!