Goal: Make 2 different get requests and use the data together from the two requests.
The Issue: I need to use the the data outside of .then({}) as I can use it for my purpose.
Following the simplified version of what im trying to do.
function main(){
const data1 = getData(URL1).then((data) => {
console.log(data) //I have access to data here
}
const data2 = getData(URL2).then((data) => {
console.log(data) //I have access to data here
}
console.log(data1) // I get Promise { <pending> }
console.log(data2) // Same as above
<Do something with data1 and data2 here>
}
async function getData(url){
let data = (await axios.get(url)).data
}