I’m new to Javascript promises and I’m trying to hit two API endpoints before running some Javascript. My expectation was that the console output would be:
GET ConfigData Now...
hello
GET Resales Now...
world
Finished here too...
Finished
Instead the Finished
console log appears to never reached nor is the "Finished here too..."
from the allDone()
function.
function getConfigData() {
console.log('GET ConfigData Now...');
return new Promise((resolve) => {
console.log("hello");
});
}
function getResales() {
console.log('GET Resales Now...');
return new Promise((resolve) => {
console.log("world");
});
}
function allDone() {
console.log('allDone Now...');
return new Promise((resolve) => {
console.log("Finished");
});
}
async function getData() {
await Promise.allSettled([getConfigData(), getResales()]);
console.log(config);
console.log(fullResales);
await Promise.allSettled([allDone()]);
console.log('Finished here too..');
}
getData()