0π
Is it possible to check whether the prop βtrashDataβ has loaded all
the items it needs from the api before firing the relevant function to
create the markers?
You can use Promise.all() : you push all your requests to the API in an array of Promises, and then you wait for it with Promise.all().
const promiseN = new Promise((resolve, reject) => {
getDataFromApi().then((result) => {
resolve(result);
}});
Promise.all([promise1, ..., promiseN]).then((values) => {
console.log(values);
});
Source:stackexchange.com