0

I'm trying to code a program that makes 3 requests to 3 different urls

// 1st request
var currentPlayers = await getCurrentPlayers(gId);
// 2nd request
var reviewText = await getReviewText(gId);

// 3rd request
 request({

Right now this takes like 1.5s to run through all 3 requests because it waits for the previous request to complete. Is there a way I can run all 3 at the same time, but then wait to print it all at the same time? There's another example below if I explained it poorly.


Currently:

Time elapsed v

1st request: 0.236s

2nd request: 0.715s

3rd request + print: 1.286s


What I want:

Time elapsed v

1st request: 0.236s

2nd request: 0.479s

3rd request + print: 0.571s

1 Answers1

0

figured it out, used promise.all()