Questions tagged [promise.all]
104 questions
0
votes
0 answers
Correctly use of Promises and await/async functions
I'm working in a Backend For Frontend (BFF) that receive a request by front end, the bff request an another api and with responses, creates the object to return to front end.
I would like to know if i'm using promises and await call correctly, there…

RAFAEL DA SILVA
- 99
- 2
- 11
0
votes
1 answer
Custom for..of using queue to solve concurrency in promises yields slower requests than Promise.all
here is my problem:
I have a stack of x promises that I want to solve 5 at a time (basically what Plimit does)
Here is the code that I implemented using for...of
async queuefy(items, concurrency, callback) {
console.log(items.length);
let…
0
votes
1 answer
How to execute the writeFileSync() only after the Promise.all() loop completion along with setTimeOut() using javascript?
I am reading a .txt file data and calling the 3rd party api to fetch more data using .txt file data as arguments continuously. For that I am running an await Promise.all() with map() loop using setTimeOut() function of delay 2 seconds so that 3rd…

Biku7
- 450
- 6
- 16
0
votes
3 answers
Promise.all convert result with parameter from nested loop
The following loop to call an async function, here a smart contract interaction using web3. I want to get the balance of an array of token by calling balanceOf() and convert it subsequently with the attached usdrate. For parallel processing I am…

Homer
- 239
- 2
- 11
0
votes
0 answers
Resolving multiple promises from a for loop - Promise.all
I am having issues resolving multiple promises from a for loop. I am fairly new to js, and I know this section of my code is a bit of a mess. I am trying to pull together financial data from multiple sources; yfapi and my database then sanitize it…
0
votes
1 answer
Fetch to return only one value from mapped urls
I'm in the process of lifting the state up in order to compare ids between the single pokemonCard and the clicked card and make it so that only the clicked card will change from 'captured' to 'not captured'.
At the moment when I try to fetch a…

geek101
- 87
- 1
- 11
0
votes
1 answer
Return object from Promise.all(...)
I am using an API to retrieve data (of several airports), based on their airport codes...
async function airpt(codes){
const airportCredential = {
"method": "GET",
"headers": {
"x-rapidapi-host":…

Dirk Albrecht
- 61
- 4
0
votes
1 answer
Pushing promises in an array the array remains null
I am pushing the promises in promises =[] array but when passing the promises in promises. All the array remains null which resolves and send null result if my code has any issue please answer
searchProductVariant: (start, end, combinations) =>…

Faizan Afridi
- 13
- 3
0
votes
2 answers
How to use axios to `fetch all()`
I don't understand how to use axios to fetch data from an array of urls. But I can do it with fetch. The following code works perfectly:
const url = 'https://vimeo.com/api/oembed.json?url='
async index(videoUrls = []) {
try {
const response…

John
- 32,403
- 80
- 251
- 422
0
votes
2 answers
Promises: combine single resolve methods and Promise.all()
I have multiple promises fetching different assets. I want to achieve:
Executing some code first to handle some of these promises via then().
When everything is resolved/fetched, executing some code that launches my app via Promise.all().then().
I…

Yosko
- 329
- 1
- 4
- 15
0
votes
2 answers
What is going on with this syntax? (let results = [], i;) I have never seen two values assigned to a variable
I found this example of how to implement a Promise.all method.
function all(iterable){ // take an iterable
// `all` returns a promise.
return new Promise(function(resolve, reject){
let counter = 0; // start with 0 things to wait for
…

jhaubrich.com
- 79
- 2
- 10
0
votes
2 answers
Issue Promise.all()
I want to declare an array of empty promises
then resolve them manually, but it is not working ?
const tab = [1]
let promises = tab.map(e => new Promise(() => { }))
setTimeout(() => {
promises[0] = Promise.resolve()
},…

anesboz
- 412
- 4
- 10
0
votes
1 answer
Javascript Promise.all results from fetching multiple apis not rendering in the React Native FlatList
I am using Promise.all in order to fetch multiple apis.
const ListScreen = () => {
const first = fetch('https://EXAMPLEAPI').then(resp => resp.json())
const second = fetch('https://EXAMPLEAPI').then(resp => resp.json())
const third =…

Florin
- 9
- 6
0
votes
0 answers
Trying to measure the difference between promise.all and separate fetch calls and getting weird results
Inside a function i have two blocks of code where i am trying to measure processing time of my api calls. Here's the code:
const start1 = new Date().getTime();
const trendingMoviesDay = await mainPageAPI.getTrendingMovies(true);
const…

nonamenoname
- 43
- 4
0
votes
1 answer
how to return from promise.all in typescript?
I have a list of urls which I need to fetch all of them so I used fetch and then promise.all, However, I don't know how to return the result of promises.
let photos_info = [];
function get_photos(urls) {
var promises = urls.map((url) =>…

Menna T-Allah Magdy
- 27
- 7