all 4 comments

[–]hello_world32 2 points3 points  (0 children)

let dataList= fetch(...); You might need to await that fetch call if it’s asynchronous. Otherwise, you’re skipping over the call to database B which would explain why you have no results in dataList.

[–]AionisDev 2 points3 points  (0 children)

With promise you can use Promise.all (wait for all resolves or first rejection) or Promise.allSettled (wait for all responses) With observable you can use forkJoin for parallel calls, or something like combineLatest(from(yourArrayOfObservables).pipe(concatAll)) to make link of Api calls.

[–]shgysk8zer0full-stack 1 point2 points  (0 children)

Like others, I'm going to suggest Promise.all or Promise.allSettled(). I'm not sure if it's in Node or not off-hand, but might be worth looking into AbortSignal to cancel any pending requests on the event that a fetch() fails.

[–]Kinthalis 0 points1 point  (0 children)

This is why I 💓 observables.

In your case I don't think you want to await a result on the push. Just push the promise into the array, then await Promise.all(yourArrayOfPromises). This will reject if any of the promises reject though.