I'm working with an async function to try and pull data into an Array with Axios. When I log the data inside the forEach below, it shows up, but when I log it outside the forEach, it returns blank. I assume this is because the program is still running, but I'm not sure how to solve without a timeout.
const user = async(IDs) => {
var output;
var URL;
var result = [];
IDs[0].forEach(async(id) => {
URL = "https://example-api.com/" + id;
output = await axios.get(URL)
.then(function(data){
result.push(data.data.text);
console.log(result) // Returns the data
});
})
console.log(result) // returns blank
}