Questions tagged [promise.all]
104 questions
1
vote
1 answer
Working with multiple API calls from a Node/Express intermediate API, trying to use promise.all()
I am discovering all kinds of gaps in my understanding during this project. I am working on building an intermediate API server. Some end-points take an array of info, then make an external call for each piece of info, then do some manipulation of…

Jeffrey Bentley
- 43
- 5
1
vote
2 answers
how to use Promise.All with forEach loop in js
after reviewing a number of questions around for/foreach loops I am still not able to get an output of a promise.all batch of functions.
The goal is to call each iteration of doSleepNow() synchronously, but wait in the Promise.all until all results…

art vanderlay
- 2,341
- 4
- 35
- 64
1
vote
1 answer
Typescript doesn't infer types for Promise.all()
Please explain someone the reason and mechanics of that TS doesn't match the types for a (string vs 'test') matching those for b at the same time. How can I solve this? The playground is here. Thank you in advance.
(async () => {
const [a]:…

Fox Amadeus
- 196
- 1
- 1
- 11
1
vote
2 answers
Js await function inside a map
I have an array of category ids in order, I have to make a map and fetch the items from these categories and in the end keep the original order of the array
what I've been doing:
const info = []
Promise.all(categoryItem.next_steps.map((next_step) =>…

Thyi
- 59
- 1
- 6
1
vote
1 answer
When does Promise.all actually queue a microtask?
So i am new to promises and i am trying some stuff to figure out what's going on under the hood. From what i read a Job is queued to the Microtask queue by .then immediately after the promise the method was chained to…

Sasho32
- 25
- 4
1
vote
1 answer
How do I use Promise.all results in a React component?
I need to figure out how to fetch multiple GeoJSON files from my public folder and render the coordinates in a React component. Here is the relevant code snippet:
export const CoordinatesComponent = () => {
const [data, setData]: any =…

saganaga
- 63
- 7
1
vote
1 answer
Javascript Promise.all execution sequence question
When I execute the below Javascript promise.all() code I get the output as
hi
50
But is what I was expecting the output to be
50
hi
Can some one please explain me why "Hi" appeared first and then 50
Below is the code
let p1 =…

priyanka sunke
- 11
- 1
1
vote
2 answers
NodeJS: How to use Promise.all in order to execute a method once multiple requests are executed?
I am having a NodeJS project, where I have array of N parameters and I need to call an endpoint N times (once with each parameter). Then I need to listen once all the responses are returned and to execute a certain function only once all the results…

delux
- 1,694
- 10
- 33
- 64
1
vote
1 answer
Promise.all with external resolve never resolves
I'm working on a SPA (Single Page Application) project and need to load files in a dynamic and controlled way (CSS, HTML and JS)
I created the structure below (in this example only for CSS), but although the files are injected into the page, the…

hericklr
- 197
- 1
- 8
1
vote
1 answer
Console.log as HTTP requests are happening in promise array
I am making an HTTP request to an API for as many entries there are on an array.
What I am trying to do is console.log each time is doing a request but I am unable to make the promise log it as it happens, it'll wait for all to be done and then it…

Álvaro
- 2,255
- 1
- 22
- 48
1
vote
1 answer
Syntax for using Promise.all() result to perform another query
I have a Promise.all() that performs two queries one after the other. In the result of the Promise.all() I want to perform a third query using the result from the second query.
How would I create a function() that I can cleanly use inside the…

DIRTY DAVE
- 2,523
- 2
- 20
- 83
1
vote
4 answers
fetch result from API returns undefined
I am trying to fetch data from an API but keep getting undefined as result. I am using promise.all to chain API calls, and then chaining promises to do other operations on data. I seem to be unable to get my results to be passed to state.
Here's the…

Eke Eke
- 25
- 10
1
vote
3 answers
How do I convert a JS promise to another object
So I have an asynchronous function that I need to call a number of times. Naturally, I would like to use Promise.all
const promises = [];
ids.forEach((id) => {
stockoutPromises.push(
asyncFunc(id),
});
});
results[] =…

Kramer
- 927
- 2
- 13
- 30
0
votes
1 answer
What is the proper way to write conditional statement inside flatMap with Promise.all in Javascript
I am working on a flatMap with Promise.all; there are two condition inside flatMap, the originalObj is for checking whether originalObj.state is false or not, then implement the insertRealStartTime, and in every event, I will implement the…

TungTung
- 163
- 7
0
votes
0 answers
Include Images in html string to pdf file download
i have the following function which takes lots of html strings and converts them into pdf files:
async signedAgreements(documentstoDownload) {
this.loading = true;
// Create an array to hold the promises of each download operation
…

BranchCoder
- 1
- 3