Questions tagged [promise.all]

104 questions
0
votes
1 answer

I want to make 15 concurrent calls to an API using Promise.all( ) rather than successive calls. I can't figure out what I am doing wrong

Caveat: I'm learning to work with JavaScript Promises and API calls, so I try to write the code in promise.then format as well as async / await, so I know how to use both. I have a container that I am initially filling with images from 15 successive…
RK3110
  • 15
  • 4
0
votes
1 answer

How to get data from 2 api and view data in angular?

Ihave 2 api ( users and category ), and I have relationship between this api in category id, and I have user Promise.all. How can I video this data in html code? My Code : frist API ( name in posts ): { "list": [ { "id": 1, …
Kareem
  • 47
  • 8
0
votes
0 answers

express-validation sequential processing

I am following this guide running-imperatively and trying to implement the sequential processing sample. const validate = validations => { return async (req, res, next) => { for (let validation of validations) { const result = await…
vava044
  • 51
  • 8
0
votes
0 answers

Multiple Api Calls with Promise.all does return undefined

I have an array of marinas, for which I want to make api calls. The Problem is that the result will arrive after, the return. Can anyone help me please? getAllChangeRequests(): Observable { console.log('getAllChangeRequests'); …
skuettel
  • 13
  • 2
0
votes
1 answer

Node.js Promise.all Then not Firing

I am trying to do a very simple task using promises. I have multiple directories, each directory has a content.txt file in it. I need to find that file and return its URL. Once all URL's are returned I want to execute a function called 'task_ended'.…
0
votes
2 answers

Typescript Function returns before promise.all finishes

I have a code as follow export class MyHandler { entry = async (data: string[]): Promise> { const response: Map = new Map(); Promise.all( data.map(async (item) => { …
markfw
  • 683
  • 2
  • 9
  • 22
0
votes
1 answer

Alternative to Promise.all for loading many resources simultaneously?

I have the following code, which works: interface MyImages { apple: HTMLImageElement, banana: HTMLImageElement, carrot: HTMLImageElement } async function fetchImages(): Promise { const images = await Promise.all([ …
Ryan Peschel
  • 11,087
  • 19
  • 74
  • 136
0
votes
0 answers

When fetching from 2 different endpoints in React Native, how would I handle duplicate ID's when rendering lists and keys?

I have been experimenting with fetching data from multiple API's using a Promise.all, and setting the data in state. useEffect(() => { Promise.all([ fetch("https://api.punkapi.com/v2/beers"), fetch("https://api.sampleapis.com/beers/ale"), …
0
votes
0 answers

How can I get all my values from a Promise and for each loop to not just log to the console but to store in an array to use in react

Right now I am getting a list of 10 url's from a promise from firebase and I then logging them to the console. What I would like to do is store the list in an object but I don't know how to return it from the promise to use elsewhere in my code. I…
Evan
  • 11
  • 2
0
votes
1 answer

How to handle this promise.all case?

We have a parallel promise call:- promise.all([p1,p2]).then().catch() here p1,p2 are 2 different promise calls . p1 - reject for some condition and show e1 p2 - reject for some condition and show e2 p1 - resolve then do something p2 - do not…
0
votes
0 answers

How To Count Number Hotels With Same City?

In database there are multiple hotels are available of the city same as that of query but I'm getting output as [0,0,0] what's the problem, I'm not able to understand why this is happening? ` exports.countByCity = async (req, res, next) => { const…
0
votes
0 answers

How to Promise.all() in SuiteScript 2.0 (Netsuite)

So the scenario is like this: I have a Suitelet that displays lines, lines are marked with a checkbox by a user and then a "submit" button is clicked. That button calls a Client Script function that goes over the selected lines in a loop and sends…
0
votes
2 answers

I wanted to get users from an array of names but it throws an error

Create an async function getUsers(names), that gets an array of GitHub logins, fetches the users from GitHub and returns an array of GitHub users. The GitHub url with user information for the given USERNAME is:…
0
votes
1 answer

Promise-all for array paths images

let newArr = []; let paths = ['1.jpg', '2.jpg', '3.jpg']; function promiseAllImg(arr) { for (let i = 0; i < arr.length; i++) { let image = document.createElement('img'); image.src = arr[i]; return new…
0
votes
2 answers

How pg-promise handles transactions with Promise.all()

In one of my projects, I want to execute 2 queries in parallel with pg-promise. I have these queries wrapped inside the transaction as added below. I am also using Promise.all() to make database calls in paralllel. I want to understand how this…