You want something like this assuming whatever you use to call the web service, fetch in my example, returns a promise.
const ids = [23, 17, 45]; const promises = ids.map(i’d => fetch(urlPrefix + id)); const results - Promise.all(promises); You’ll have to correct the URLs being passed to fetch, but that should get you started. --- R. Mark Volkmann Object Computing, Inc. > On Oct 24, 2017, at 3:56 PM, [email protected] wrote: > > Hi > I am new to node js. I am facing an issue. > I have 3 ids. I am iterating in for loop. For each value I am calling web > service. The web service is find by id by passing each id. What I noticed is > that it always takes the last id. > for eg: id are 10, 20, 30 > When I call any service by passing in for loop it always takes 30. > Any help is appreciated. > > Regards > -- > Job board: http://jobs.nodejs.org/ > New group rules: > https://gist.github.com/othiym23/9886289#file-moderation-policy-md > Old group rules: > https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines > --- > You received this message because you are subscribed to the Google Groups > "nodejs" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/nodejs/88274485-8c08-4e79-bb5f-829655b97c7e%40googlegroups.com. > For more options, visit https://groups.google.com/d/optout. -- Job board: http://jobs.nodejs.org/ New group rules: https://gist.github.com/othiym23/9886289#file-moderation-policy-md Old group rules: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines --- You received this message because you are subscribed to the Google Groups "nodejs" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/nodejs/5C91D57B-0D72-49FA-B5F5-301103DBA30A%40gmail.com. For more options, visit https://groups.google.com/d/optout.
